home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / screen3 / part03 < prev    next >
Encoding:
Text File  |  1991-12-19  |  75.4 KB  |  2,667 lines

  1. Newsgroups: comp.sources.unix
  2. From: jnweiger@immd4.informatik.uni-erlangen.de (Juergen Weigert)
  3. Subject: v25i043: Screen3 - multiple windows on an ASCII terminal, Part03/08
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: jnweiger@immd4.informatik.uni-erlangen.de (Juergen Weigert)
  8. Posting-Number: Volume 25, Issue 43
  9. Archive-Name: screen3/part03
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 3 (of 8)."
  18. # Contents:  CHANGES COPYING config/config.gould_np1 help.c screen.h
  19. #   window.c
  20. # Wrapped by vixie@cognition.pa.dec.com on Thu Dec 19 17:36:05 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'CHANGES'\"
  24. else
  25. echo shar: Extracting \"'CHANGES'\" \(9292 characters\)
  26. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  27. X3.1.1
  28. X------
  29. X
  30. iScreen is now under the GNU copyleft license. See file COPYING.
  31. X
  32. command line option -A. $LINES, $COLUMNS improved.
  33. X
  34. C-A : vbell_wait <sec>
  35. X
  36. XXENIX support (Ronald Khoo)
  37. X
  38. SYSV has uname() instead of gethostname().
  39. X
  40. hpux has setresuid.
  41. X
  42. ClearScreen now saves image to scrollback buffer.
  43. X
  44. mips has setenv.
  45. X
  46. numerous bugfixes.
  47. X
  48. X3.1 finally released version.
  49. X=============================
  50. X
  51. X3.0.99: last minute changes:
  52. X----------------------------
  53. X
  54. MIPS support (J{rvinen Markku)
  55. X
  56. SVR4 support (Marc Boucher)
  57. X
  58. secopen() secfopen() calls replace stat/access/open.
  59. C-a : echo improved.
  60. X'register int'
  61. X
  62. Changes up to Screen 3.0 Patchlevel 7
  63. X=====================================
  64. X
  65. Better terminfo support: Screen now checks if a termcap/info
  66. entry which the name "screen.$TERM" does exist. Look in the
  67. X"VIRTUAL TERMINAL" section of the manual for more details.
  68. X
  69. Many security improvements.
  70. X
  71. ScrollRegion() bug fixed which caused slow scrolling if AL
  72. or DL was used.
  73. X
  74. Pyramid and Ultrix support added. (Tim and Larry)
  75. X  
  76. XENVIRONMENT support.
  77. X  /local/etc/screenrc checks for $SYSSCREENRC
  78. X  $HOME/.screenrc checks for $ISCREENRC and $SCREENRC
  79. X  /local/screens checks for $ISCREENDIR and $SCREENDIR
  80. X  .screenrc understands ${VAR} and $VAR .
  81. X
  82. screen 3.0 Patchlevel 6
  83. X=======================
  84. X
  85. X.screenrc:
  86. X  screen now only opens the windows you explicitly ask for. if you 
  87. X  specify none, you still get one window, of course.
  88. X
  89. screen 3.0. Patchlevel 5
  90. X========================
  91. X
  92. Ansi prototyping by Christos.
  93. X
  94. copy mode: CTRL-U / CTRL-D exchanged. code cleanup.
  95. X
  96. changes to screen 3.0 patchlevel 4
  97. X==================================
  98. X
  99. markkeys "string"
  100. X  allows to rebind the keys used in copy/history mode.
  101. X  string is made up of pairs "<oldchar>=<newchar>" which are separated
  102. X  by a colon. Oldchar and newchar are either single ascii characters, 
  103. X  or the two character sequence ^x, where x is an ascii character, or
  104. X  a 3 digit octal value prepended with '\'. the string "\040=.:^M=q"
  105. X  rebinds '.' to set marks, and the return rey will abort copy mode.
  106. X
  107. set scrollback 100
  108. X  resizes the scrollback history buffer to 100 lines. a default of 50
  109. X  is installed. 
  110. X
  111. A Howard Chu like scrollback history is installed. Many vi-like keys
  112. X  are added to the copy mode. The '?' key reports on cursor position.
  113. X
  114. screen 3.0 Patchlevel 3
  115. X=======================
  116. X
  117. WriteString fixed, it did kill the display variable.
  118. X
  119. Yet another LP bugfix.
  120. X
  121. non vt100 semi-graphics character support.
  122. X
  123. waynes patch fixed
  124. X
  125. screen 3.0 Patchlevel 2
  126. X=======================
  127. X
  128. wayne patches cursor motion outside scrollregions.
  129. X
  130. X.screenrc 
  131. X  monitor on|off
  132. X
  133. changes in Screen 3.0 Patchlevel 1
  134. X==================================
  135. X
  136. screen -wipe
  137. X
  138. X^A : set vbell_msg "Wuff Wuff"
  139. X
  140. Thousand enhancements: help resizible, copy'n'paste in main
  141. X  socket loop, and no more '\0' hackin'. :WS=\E8;%d;%dt:
  142. X
  143. screen can now resize windows under sunview.
  144. X
  145. X^A : set crlf on|off
  146. X  effects markroutine join.
  147. X
  148. screen learned about sized windows under X
  149. X
  150. screen -ls (-d) -q
  151. X  quiet option. We count the number of detached (attached) sessions and set
  152. X  a return value of 10+n. The -q option inhibits all startup
  153. X  warnings/messages. i.e. screen -R -q may return with code 12 or higher
  154. X  or start a new/old session.
  155. X
  156. pow_detach_msg "text string"
  157. X  new command, allows messages, terminal reset, etc. on logout caused
  158. X  by pow_detach.
  159. X
  160. X^A : learned a new keyword "set":
  161. X  commands like "login on" , "vbell off", ... affect the default for
  162. X  windows to be created. But commands like "set login off" affect
  163. X  the actual setting of this window. and not the default.
  164. X  such commands may be bound to keys. example: 
  165. X  bind 'O' set login off
  166. X  is valid in your .screenrc as well as typed at the ':' prompt.
  167. X  a bonus is ":set all" which is synonym to ":help".
  168. X  At the Colon prompt also KeyNames can be entered, alothough that makes
  169. X  not always sense.
  170. X
  171. X^A x uses a builtin lockprg, if 
  172. X  a) we don't find our lockprg, or
  173. X  b) user supplies us with the environmet variable LOCKPRG set to "builtin"
  174. X  the builtin locks until your login password is typed. on systems using
  175. X  "shadow password files" you are prompted for a password.
  176. X
  177. markroutine can append joined.
  178. X
  179. screen removes the "controlling tty" from utmp while ptys are attached.
  180. X
  181. markroutine performs CR+NL when '\n' is pressed
  182. X
  183. screen may die quietly, when no TERMCAP entry for "screen" is
  184. found, and screen is run under X-windows
  185. X
  186. X_SEQUENT_ marks sequent386_ptx
  187. X
  188. screen runs now under SunOS4.1.1 (we need setsid()!).
  189. X
  190. bug in SetForeWindow fixed.
  191. X
  192. rare markroutine bug fixed.
  193. X
  194. we dont open every file the attacher tells us.
  195. X
  196. we have now our wonderful "Wuff, Wuff" visual_bell
  197. X
  198. we have now the interprocess-communication-buffer. secure version.
  199. X
  200. X'^A =' removes the interprocess-communication-buffer.
  201. X
  202. markroutine as in 2.1
  203. X
  204. markroutine: 'a' toggles append mode,
  205. X             '>' like ' ', but immediately WriteFile(DUMP_EXCHANGE) then.
  206. X             'A' like ' ', but first switch to append mode.
  207. X
  208. X.screenrc understands "screen 2:faui09 rlogin faui09 -l jnweiger"
  209. X                  and "password none"
  210. X                  and "vbell [on|off]"
  211. X
  212. X'^A :' allows .screenrc commands "online".
  213. X
  214. screen now receives new $TERM from attacher, when it is reattached 
  215. X
  216. MakeClientSocket() fifo version does now test for access.
  217. X
  218. X.screenrc learns "hardstatus {on|off}"
  219. X
  220. termcap's VB is used for vbell if available.
  221. X
  222. Attach() code rewritten:
  223. X    screen now lists socket directory, if it does not find a suitable socket
  224. X    screen -d [host.tty] detaches a running screen. 
  225. X
  226. screen -[ls|list]
  227. X    list all sockets that we find in our sockdir
  228. X
  229. when the socket has been removed, send a SIGCHLD to the poor SCREEN 
  230. process and it will try to recover. then try a 'screen -r' again.
  231. all the socket stuff lives now in an extra file.
  232. X
  233. Major changes in version 2.4:
  234. X=============================
  235. X
  236. X*  Test version that presents the erlangen extensions from 2.0 in a 2.3
  237. X   screen.
  238. X
  239. X*  window resize support
  240. X
  241. X*  screen locking C-a x
  242. X
  243. X*  support for SYSV
  244. X
  245. X*  password protection
  246. X
  247. X*  copy & paste across screens
  248. X
  249. X*  remote detach and power detach
  250. X
  251. Major changes in version 2.3:
  252. X
  253. X*  Terminal emulation has been significantly enhanced and bugfixed.
  254. X
  255. X*  We now fully update the last character on the screen for true auto-
  256. X   margin terminals, though there may be some delay before the character
  257. X   can be safely added to the screen.  If your terminal has character
  258. X   insert it will be used to shorten the delay.
  259. X
  260. X*  Added the "termcap" .screenrc command to tweak your terminal's termcap
  261. X   entry AND to customize the termcap generated for the virtual terminals.
  262. X   See also the -L and -O command-line options, and the SCREENCAP environ-
  263. X   ment variable.
  264. X
  265. X*  Fixed screen's character handling when detached or suspended to NOT block
  266. X   the child processes in their windows -- output continues to be processed
  267. X   in the background.
  268. X
  269. X*  Added a.k.a.s (window-name aliases) that allow you to customize the
  270. X   window-information line, including being able to change the name on-
  271. X   the-fly to reflect what's currently running in the window (see the
  272. X   -k option, shellaka command, and ALSO KNOWN AS discussion in the doc).
  273. X
  274. X*  Added the ability to log the output of a window to a file (see the
  275. X   "C-a H" (log) command).
  276. X
  277. X*  Flow-control can now be set for each window and switched interactively
  278. X   (see the "flow" command, -f option, and FLOW CONTROL discussion).
  279. X
  280. X*  Individual windows can be included or excluded from mention in the
  281. X   /etc/utmp file (see the "login" command and -l option).
  282. X
  283. X*  Added an activity monitor, which allows you to have a window watched for
  284. X   the start of any output and alert you when it occurs (see the "C-a M"
  285. X   (monitor) command).
  286. X
  287. X*  Enhanced the information in the window-information line to keep track of
  288. X   windows that have: logging turned on '(L)'; beeped in the background '!';
  289. X   became active while being monitored '@' (see the "C-a w" (windows) command).
  290. X
  291. X*  Added an on-line help display that lists all the commands and their
  292. X   key bindings (see the "C-a ?" (help) command).
  293. X
  294. X*  Extended handling of the beep message (and also the new activity message)
  295. X   to allow '~' to specify a literal beep (see the "beep" and "activity"
  296. X   .screenrc commands).
  297. X
  298. X*  You can now set the default action on receipt of a hangup signal:  detach
  299. X   or terminate (see the "autodetach" .screenrc command).
  300. X
  301. X*  Routing of characters to their virtual terminals has been enhanced to
  302. X   not drop characters nor (in rare circumstances) hang up screen.
  303. X
  304. X*  The NFS compatibility has been enhanced.
  305. X
  306. Major changes in version 2.0a:
  307. X
  308. X*  Screen allows you to `detach' the "screen" session from the physical
  309. X   terminal and resume it at a later point in time (possibly on a
  310. X   different terminal or in a different login session).
  311. X
  312. X  To get an impression of this functionality do the following:
  313. X
  314. X     - call "screen" and create a couple of windows
  315. X     - type Control-A Control-D (screen terminates; you are back
  316. X       in the shell)
  317. X     - call "screen -r" to resume the detached screen
  318. X
  319. X*  Screen supports multiple character sets and the ISO 2022 control
  320. X   functions to designate and switch between character sets.
  321. X   This allows you, for instance, to make use of the VT100 graphics
  322. X   character set or national character sets.
  323. END_OF_FILE
  324. if test 9292 -ne `wc -c <'CHANGES'`; then
  325.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  326. fi
  327. # end of 'CHANGES'
  328. fi
  329. if test -f 'COPYING' -a "${1}" != "-c" ; then 
  330.   echo shar: Will not clobber existing file \"'COPYING'\"
  331. else
  332. echo shar: Extracting \"'COPYING'\" \(9934 characters\)
  333. sed "s/^X//" >'COPYING' <<'END_OF_FILE'
  334. X            GNU GENERAL PUBLIC LICENSE
  335. X             Version 1, February 1989
  336. X
  337. X Copyright (C) 1989 Free Software Foundation, Inc.
  338. X                    675 Mass Ave, Cambridge, MA 02139, USA
  339. X Everyone is permitted to copy and distribute verbatim copies
  340. X of this license document, but changing it is not allowed.
  341. X
  342. X                Preamble
  343. X
  344. X  The license agreements of most software companies try to keep users
  345. at the mercy of those companies.  By contrast, our General Public
  346. License is intended to guarantee your freedom to share and change free
  347. software--to make sure the software is free for all its users.  The
  348. General Public License applies to the Free Software Foundation's
  349. software and to any other program whose authors commit to using it.
  350. You can use it for your programs, too.
  351. X
  352. X  When we speak of free software, we are referring to freedom, not
  353. price.  Specifically, the General Public License is designed to make
  354. sure that you have the freedom to give away or sell copies of free
  355. software, that you receive source code or can get it if you want it,
  356. that you can change the software or use pieces of it in new free
  357. programs; and that you know you can do these things.
  358. X
  359. X  To protect your rights, we need to make restrictions that forbid
  360. anyone to deny you these rights or to ask you to surrender the rights.
  361. These restrictions translate to certain responsibilities for you if you
  362. distribute copies of the software, or if you modify it.
  363. X
  364. X  For example, if you distribute copies of a such a program, whether
  365. gratis or for a fee, you must give the recipients all the rights that
  366. you have.  You must make sure that they, too, receive or can get the
  367. source code.  And you must tell them their rights.
  368. X
  369. X  We protect your rights with two steps: (1) copyright the software, and
  370. X(2) offer you this license which gives you legal permission to copy,
  371. distribute and/or modify the software.
  372. X
  373. X  Also, for each author's protection and ours, we want to make certain
  374. that everyone understands that there is no warranty for this free
  375. software.  If the software is modified by someone else and passed on, we
  376. want its recipients to know that what they have is not the original, so
  377. that any problems introduced by others will not reflect on the original
  378. authors' reputations.
  379. X
  380. X  The precise terms and conditions for copying, distribution and
  381. modification follow.
  382. X
  383. X            GNU GENERAL PUBLIC LICENSE
  384. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  385. X
  386. X  0. This License Agreement applies to any program or other work which
  387. contains a notice placed by the copyright holder saying it may be
  388. distributed under the terms of this General Public License.  The
  389. X"Program", below, refers to any such program or work, and a "work based
  390. on the Program" means either the Program or any work containing the
  391. Program or a portion of it, either verbatim or with modifications.  Each
  392. licensee is addressed as "you".
  393. X
  394. X  1. You may copy and distribute verbatim copies of the Program's source
  395. code as you receive it, in any medium, provided that you conspicuously and
  396. appropriately publish on each copy an appropriate copyright notice and
  397. disclaimer of warranty; keep intact all the notices that refer to this
  398. General Public License and to the absence of any warranty; and give any
  399. other recipients of the Program a copy of this General Public License
  400. along with the Program.  You may charge a fee for the physical act of
  401. transferring a copy.
  402. X
  403. X  2. You may modify your copy or copies of the Program or any portion of
  404. it, and copy and distribute such modifications under the terms of Paragraph
  405. X1 above, provided that you also do the following:
  406. X
  407. X    a) cause the modified files to carry prominent notices stating that
  408. X    you changed the files and the date of any change; and
  409. X
  410. X    b) cause the whole of any work that you distribute or publish, that
  411. X    in whole or in part contains the Program or any part thereof, either
  412. X    with or without modifications, to be licensed at no charge to all
  413. X    third parties under the terms of this General Public License (except
  414. X    that you may choose to grant warranty protection to some or all
  415. X    third parties, at your option).
  416. X
  417. X    c) If the modified program normally reads commands interactively when
  418. X    run, you must cause it, when started running for such interactive use
  419. X    in the simplest and most usual way, to print or display an
  420. X    announcement including an appropriate copyright notice and a notice
  421. X    that there is no warranty (or else, saying that you provide a
  422. X    warranty) and that users may redistribute the program under these
  423. X    conditions, and telling the user how to view a copy of this General
  424. X    Public License.
  425. X
  426. X    d) You may charge a fee for the physical act of transferring a
  427. X    copy, and you may at your option offer warranty protection in
  428. X    exchange for a fee.
  429. X
  430. Mere aggregation of another independent work with the Program (or its
  431. derivative) on a volume of a storage or distribution medium does not bring
  432. the other work under the scope of these terms.
  433. X
  434. X  3. You may copy and distribute the Program (or a portion or derivative of
  435. it, under Paragraph 2) in object code or executable form under the terms of
  436. Paragraphs 1 and 2 above provided that you also do one of the following:
  437. X
  438. X    a) accompany it with the complete corresponding machine-readable
  439. X    source code, which must be distributed under the terms of
  440. X    Paragraphs 1 and 2 above; or,
  441. X
  442. X    b) accompany it with a written offer, valid for at least three
  443. X    years, to give any third party free (except for a nominal charge
  444. X    for the cost of distribution) a complete machine-readable copy of the
  445. X    corresponding source code, to be distributed under the terms of
  446. X    Paragraphs 1 and 2 above; or,
  447. X
  448. X    c) accompany it with the information you received as to where the
  449. X    corresponding source code may be obtained.  (This alternative is
  450. X    allowed only for noncommercial distribution and only if you
  451. X    received the program in object code or executable form alone.)
  452. X
  453. Source code for a work means the preferred form of the work for making
  454. modifications to it.  For an executable file, complete source code means
  455. all the source code for all modules it contains; but, as a special
  456. exception, it need not include source code for modules which are standard
  457. libraries that accompany the operating system on which the executable
  458. file runs, or for standard header files or definitions files that
  459. accompany that operating system.
  460. X
  461. X  4. You may not copy, modify, sublicense, distribute or transfer the
  462. Program except as expressly provided under this General Public License.
  463. Any attempt otherwise to copy, modify, sublicense, distribute or transfer
  464. the Program is void, and will automatically terminate your rights to use
  465. the Program under this License.  However, parties who have received
  466. copies, or rights to use copies, from you under this General Public
  467. License will not have their licenses terminated so long as such parties
  468. remain in full compliance.
  469. X
  470. X  5. By copying, distributing or modifying the Program (or any work based
  471. on the Program) you indicate your acceptance of this license to do so,
  472. and all its terms and conditions.
  473. X
  474. X  6. Each time you redistribute the Program (or any work based on the
  475. Program), the recipient automatically receives a license from the original
  476. licensor to copy, distribute or modify the Program subject to these
  477. terms and conditions.  You may not impose any further restrictions on the
  478. recipients' exercise of the rights granted herein.
  479. X
  480. X  7. The Free Software Foundation may publish revised and/or new versions
  481. of the General Public License from time to time.  Such new versions will
  482. be similar in spirit to the present version, but may differ in detail to
  483. address new problems or concerns.
  484. X
  485. XEach version is given a distinguishing version number.  If the Program
  486. specifies a version number of the license which applies to it and "any
  487. later version", you have the option of following the terms and conditions
  488. either of that version or of any later version published by the Free
  489. Software Foundation.  If the Program does not specify a version number of
  490. the license, you may choose any version ever published by the Free Software
  491. XFoundation.
  492. X
  493. X  8. If you wish to incorporate parts of the Program into other free
  494. programs whose distribution conditions are different, write to the author
  495. to ask for permission.  For software which is copyrighted by the Free
  496. Software Foundation, write to the Free Software Foundation; we sometimes
  497. make exceptions for this.  Our decision will be guided by the two goals
  498. of preserving the free status of all derivatives of our free software and
  499. of promoting the sharing and reuse of software generally.
  500. X
  501. X                NO WARRANTY
  502. X
  503. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  504. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  505. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  506. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  507. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  508. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  509. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  510. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  511. REPAIR OR CORRECTION.
  512. X
  513. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  514. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  515. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  516. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  517. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  518. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  519. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  520. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  521. POSSIBILITY OF SUCH DAMAGES.
  522. X
  523. X             END OF TERMS AND CONDITIONS
  524. END_OF_FILE
  525. if test 9934 -ne `wc -c <'COPYING'`; then
  526.     echo shar: \"'COPYING'\" unpacked with wrong size!
  527. fi
  528. # end of 'COPYING'
  529. fi
  530. if test -f 'config/config.gould_np1' -a "${1}" != "-c" ; then 
  531.   echo shar: Will not clobber existing file \"'config/config.gould_np1'\"
  532. else
  533. echo shar: Extracting \"'config/config.gould_np1'\" \(14876 characters\)
  534. sed "s/^X//" >'config/config.gould_np1' <<'END_OF_FILE'
  535. X/* Copyright (c) 1991
  536. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  537. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  538. X * Copyright (c) 1987 Oliver Laumann
  539. X *
  540. X * This program is free software; you can redistribute it and/or modify
  541. X * it under the terms of the GNU General Public License as published by
  542. X * the Free Software Foundation; either version 1, or (at your option)
  543. X * any later version.
  544. X *
  545. X * This program is distributed in the hope that it will be useful,
  546. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  547. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  548. X * GNU General Public License for more details.
  549. X *
  550. X * You should have received a copy of the GNU General Public License
  551. X * along with this program (see the file COPYING); if not, write to the
  552. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  553. X *
  554. X * Noteworthy contributors to screen's design and implementation:
  555. X *    Wayne Davison (davison@borland.com)
  556. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  557. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  558. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  559. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  560. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  561. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  562. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  563. X *    Marc Boucher (marc@CAM.ORG)
  564. X *
  565. X ****************************************************************
  566. X * $Id: config.gould_np1,v 1.5 91/10/06 11:58:22 jnweiger Exp $ FAU
  567. X */
  568. X
  569. X/*
  570. X * config file by Chris Fletcher <ma8caf@uk.ac.bath.gdt>
  571. X * The config file has been set up without the set uid and writing to
  572. X * /etc/utmp options.
  573. X ****************************************************************
  574. X */
  575. X
  576. X/*
  577. X *        Beginning of User Configuration Section
  578. X *
  579. X * First off, you should decide if you intend to install screen set-uid to
  580. X * root.  This isn't necessary to use screen, but it allows the pseudo-ttys
  581. X * to be set to their proper owner (for security purposes), /etc/utmp to be
  582. X * updated, and /dev/kmem to be accessed to read the load average values.
  583. X *
  584. X * An alternative to installing screen set-uid root is to install it set-gid
  585. X * utmp (with the file /etc/utmp installed to be group-utmp writable) or
  586. X * set-gid kmem (with /dev/kmem set to be group-kmem readable) or some other
  587. X * custom group to give you both.  The final alternative is to omit /etc/utmp
  588. X * updating and the /dev/kmem reading (see the following defines) and simply
  589. X * run screen as a regular program -- its major functions will be unaffected.
  590. X */
  591. X
  592. X
  593. X/*
  594. X * Define POSIX if your system supports IEEE Std 1003.1-1988 (POSIX).
  595. X */
  596. X#undef POSIX
  597. X
  598. X/*
  599. X * Define BSDJOBS if you have BSD-style job control (both process
  600. X * groups and a tty that deals correctly with them).
  601. X */
  602. X#define BSDJOBS
  603. X
  604. X/*
  605. X * Define TERMIO if you have struct termio instead of struct sgttyb.
  606. X * This is usually the case for SVID systems, where BSD uses sgttyb.
  607. X * POSIX systems should define this anyway, even though they use
  608. X * struct termios.
  609. X */
  610. X#undef TERMIO
  611. X
  612. X/*
  613. X * Define TERMINFO if your machine emulates the termcap routines
  614. X * with the terminfo database.
  615. X * Thus the .screenrc file is parsed for
  616. X * the command 'terminfo' and not 'termcap'.
  617. X */
  618. X#undef TERMINFO
  619. X
  620. X/*
  621. X * Define SYSV if your machine is SYSV complient (Sys V, HPUX, A/UX)
  622. X */
  623. X#undef SYSV
  624. X
  625. X/*
  626. X * Define SIGVOID if your signal handlers return void.  On older
  627. X * systems, signal returns int, but on newer ones, it returns void.
  628. X */
  629. X#undef SIGVOID 
  630. X
  631. X/*
  632. X * Define DIRENT if your system has <dirent.h> instead of <sys/dir.h>
  633. X */
  634. X#undef DIRENT
  635. X
  636. X/*
  637. X * If screen is going to be installed set-uid root, you MUST define SUIDROOT.
  638. X */
  639. X#undef SUIDROOT
  640. X
  641. X/*
  642. X * If screen is installed with permissions to update /etc/utmp (such as if
  643. X * it is installed set-uid root), define UTMPOK.  Set LOGINDEFAULT to one (1)
  644. X * if you want entries added to /etc/utmp by default, else set it to zero (0).
  645. X */
  646. X#undef UTMPOK
  647. X#define LOGINDEFAULT    0
  648. X
  649. X/*
  650. X * If your system has getutent(), pututline(), etc. to write to the
  651. X * utmp file, define GETUTENT.
  652. X */
  653. X#undef GETUTENT
  654. X
  655. X/*
  656. X * Define UTHOST if the utmp file has a host field.
  657. X */
  658. X#define UTHOST
  659. X
  660. X/*
  661. X * If UTMPOK is defined and your system (incorrectly) counts logins by
  662. X * counting non-null entries in /etc/utmp (instead of counting non-null
  663. X * entries with no hostname that are not on a pseudo tty), define USRLIMIT
  664. X * to have screen put an upper-limit on the number of entries to write
  665. X * into /etc/utmp.  This helps to keep you from exceeding a limited-user
  666. X * license.
  667. X */
  668. X#undef USRLIMIT
  669. X
  670. X/*
  671. X * If screen is NOT installed set-uid root, screen can provide tty security
  672. X * by exclusively locking the ptys.  While this keeps other users from
  673. X * opening your ptys, it also keeps your own subprocesses from being able
  674. X * to open /dev/tty.  Define LOCKPTY to add this exclusive locking.
  675. X */
  676. X#undef LOCKPTY
  677. X
  678. X/*
  679. X * If your system does not have the calls setreuid() and setregid(), define
  680. X * NOREUID to force screen to use a forked process to safely create output
  681. X * files without retaining any special privileges.  (Output logging will be
  682. X * disabled, however.)
  683. X */
  684. X#undef NOREUID
  685. X
  686. X/*
  687. X * If you want the "time" command to display the current load average
  688. X * you must install screen with the needed privileges to read /dev/kmem
  689. X * and have a load average format that screen understands.  We handle the
  690. X * following formats:  3 doubles (BSD), 3 longs (sun), and 4 longs (alliant).
  691. X */
  692. X#define  LOADAV_3DOUBLES
  693. X#undef LOADAV_3LONGS
  694. X#undef  LOADAV_4LONGS
  695. X
  696. X/*
  697. X * If your system has the new format /etc/ttys (like 4.3 BSD) and the
  698. X * getttyent(3) library functions, define GETTTYENT.
  699. X */
  700. X#define GETTTYENT
  701. X
  702. X/*
  703. X * If your version of NFS supports named sockets and you install screen
  704. X * suid root, you may need to define NFS_HACK for screen to be able to
  705. X * open the sockets.
  706. X */
  707. X#undef NFS_HACK
  708. X
  709. X/*
  710. X * By default screen will create a directory named ".screen" in the user's
  711. X * HOME directory to contain the named sockets.  If this causes you problems
  712. X * (e.g. some user's HOME directories are NFS-mounted and don't support
  713. X * named sockets) you can have screen create the socket directories in a
  714. X * common subdirectory, such as /tmp or /usr/tmp.  It makes things a little
  715. X * more secure if you choose a directory where the "sticky" bit is on, but
  716. X * this isn't required.  Screen will name the subdirectories "S-$USER"
  717. X * (e.g /tmp/S-davison).
  718. X * Do not define TMPTEST unless it's for debugging purpose.
  719. X * If you want to have your socket directory in "/tmp/screens" then
  720. X * define LOCALSOCKDIR and change the definition of SOCKDIR below.
  721. X */
  722. X#undef LOCALSOCKDIR
  723. X
  724. X#ifdef LOCALSOCKDIR
  725. X# ifndef TMPTEST
  726. X#  define SOCKDIR "/local/screens"
  727. X# else
  728. X#  define SOCKDIR "/tmp/screens"
  729. X# endif
  730. X#endif
  731. X
  732. X/*
  733. X * Define USEBCOPY if the bcopy() from your system's C library supports the
  734. X * overlapping of source and destination blocks.  When undefined, screen
  735. X * uses its own (probably slower) version of bcopy().
  736. X */
  737. X#define USEBCOPY
  738. X
  739. X/*
  740. X * If you'd rather see the status line on the first line of your
  741. X * terminal rather than the last, define TOPSTAT.
  742. X */
  743. X#undef TOPSTAT
  744. X
  745. X/*
  746. X * If your system has vsprintf() and requires the use of the macros in
  747. X * "varargs.h" to use functions with variable arguments,
  748. X * define USEVARARGS.
  749. X */
  750. X#undef USEVARARGS
  751. X
  752. X/*
  753. X * Define this if your system supports named pipes.
  754. X */
  755. X#undef NAMEDPIPE
  756. X
  757. X/*
  758. X * here come the erlangen extensions to screen:
  759. X * define LOCK if you want to use a lock program for a screenlock.
  760. X * define PASSWORD for secure reattach of your screen.
  761. X * define COPY_PASTE to use the famous hacker's treasure zoo.
  762. X * define POW_DETACH to have a detach_and_logout key.
  763. X * define REMOTE_DETACH (-d option) to move screen between terminals.
  764. X * (jw)
  765. X */
  766. X#define LOCK
  767. X#define PASSWORD
  768. X#define COPY_PASTE
  769. X#define REMOTE_DETACH
  770. X#define POW_DETACH
  771. X
  772. X/*
  773. X * As error messages are mostly meaningless to the user, we
  774. X * try to throw out phrases that are somewhat more familiar
  775. X * to ...well, at least familiar to us NetHack players.
  776. X */
  777. X#define NETHACK
  778. X
  779. X/*
  780. X * and another sneaky feature: screen sources two startup files.
  781. X * first a global file with a path specified here, second
  782. X * your local $HOME/.screenrc
  783. X * Don't define this, if you don't want it.
  784. X */
  785. X#undef ETCSCREENRC "/local/etc/screenrc"
  786. X
  787. X/*
  788. X *    End of User Configuration Section
  789. X */
  790. X
  791. X/*
  792. X *        Beginning of User Configuration Section
  793. X *
  794. X * First off, you should decide if you intend to install screen set-uid to
  795. X * root.  This isn't necessary to use screen, but it allows the pseudo-ttys
  796. X * to be set to their proper owner (for security purposes), /etc/utmp to be
  797. X * updated, and /dev/kmem to be accessed to read the load average values.
  798. X *
  799. X * An alternative to installing screen set-uid root is to install it set-gid
  800. X * utmp (with the file /etc/utmp installed to be group-utmp writable) or
  801. X * set-gid kmem (with /dev/kmem set to be group-kmem readable) or some other
  802. X * custom group to give you both.  The final alternative is to omit /etc/utmp
  803. X * updating and the /dev/kmem reading (see the following defines) and simply
  804. X * run screen as a regular program -- its major functions will be unaffected.
  805. X */
  806. X
  807. X
  808. X/*
  809. X * Define POSIX if your system supports IEEE Std 1003.1-1988 (POSIX).
  810. X */
  811. X#undef POSIX
  812. X
  813. X/*
  814. X * Define BSDJOBS if you have BSD-style job control (both process
  815. X * groups and a tty that deals correctly with them).
  816. X */
  817. X#define BSDJOBS
  818. X
  819. X/*
  820. X * Define TERMIO if you have struct termio instead of struct sgttyb.
  821. X * This is usually the case for SVID systems, where BSD uses sgttyb.
  822. X * POSIX systems should define this anyway, even though they use
  823. X * struct termios.
  824. X */
  825. X#undef TERMIO
  826. X
  827. X/*
  828. X * Define TERMINFO if your machine emulates the termcap routines
  829. X * with the terminfo database.
  830. X * Thus the .screenrc file is parsed for
  831. X * the command 'terminfo' and not 'termcap'.
  832. X */
  833. X#undef TERMINFO
  834. X
  835. X/*
  836. X * Define SYSV if your machine is SYSV complient (Sys V, HPUX, A/UX)
  837. X */
  838. X#undef SYSV
  839. X
  840. X/*
  841. X * Define SIGVOID if your signal handlers return void.  On older
  842. X * systems, signal returns int, but on newer ones, it returns void.
  843. X */
  844. X#undef SIGVOID 
  845. X
  846. X/*
  847. X * Define DIRENT if your system has <dirent.h> instead of <sys/dir.h>
  848. X */
  849. X#undef DIRENT
  850. X
  851. X/*
  852. X * If screen is going to be installed set-uid root, you MUST define SUIDROOT.
  853. X */
  854. X#undef SUIDROOT
  855. X
  856. X/*
  857. X * If screen is installed with permissions to update /etc/utmp (such as if
  858. X * it is installed set-uid root), define UTMPOK.  Set LOGINDEFAULT to one (1)
  859. X * if you want entries added to /etc/utmp by default, else set it to zero (0).
  860. X */
  861. X#undef UTMPOK
  862. X#define LOGINDEFAULT    0
  863. X
  864. X/*
  865. X * If your system has getutent(), pututline(), etc. to write to the
  866. X * utmp file, define GETUTENT.
  867. X */
  868. X#undef GETUTENT
  869. X
  870. X/*
  871. X * Define UTHOST if the utmp file has a host field.
  872. X */
  873. X#define UTHOST
  874. X
  875. X/*
  876. X * If UTMPOK is defined and your system (incorrectly) counts logins by
  877. X * counting non-null entries in /etc/utmp (instead of counting non-null
  878. X * entries with no hostname that are not on a pseudo tty), define USRLIMIT
  879. X * to have screen put an upper-limit on the number of entries to write
  880. X * into /etc/utmp.  This helps to keep you from exceeding a limited-user
  881. X * license.
  882. X */
  883. X#undef USRLIMIT
  884. X
  885. X/*
  886. X * If screen is NOT installed set-uid root, screen can provide tty security
  887. X * by exclusively locking the ptys.  While this keeps other users from
  888. X * opening your ptys, it also keeps your own subprocesses from being able
  889. X * to open /dev/tty.  Define LOCKPTY to add this exclusive locking.
  890. X */
  891. X#undef LOCKPTY
  892. X
  893. X/*
  894. X * If your system does not have the calls setreuid() and setregid(), define
  895. X * NOREUID to force screen to use a forked process to safely create output
  896. X * files without retaining any special privileges.  (Output logging will be
  897. X * disabled, however.)
  898. X */
  899. X#undef NOREUID
  900. X
  901. X/*
  902. X * If you want the "time" command to display the current load average
  903. X * you must install screen with the needed privileges to read /dev/kmem
  904. X * and have a load average format that screen understands.  We handle the
  905. X * following formats:  3 doubles (BSD), 3 longs (sun), and 4 longs (alliant).
  906. X */
  907. X#define  LOADAV_3DOUBLES
  908. X#undef LOADAV_3LONGS
  909. X#undef  LOADAV_4LONGS
  910. X
  911. X/*
  912. X * If your system has the new format /etc/ttys (like 4.3 BSD) and the
  913. X * getttyent(3) library functions, define GETTTYENT.
  914. X */
  915. X#define GETTTYENT
  916. X
  917. X/*
  918. X * If your version of NFS supports named sockets and you install screen
  919. X * suid root, you may need to define NFS_HACK for screen to be able to
  920. X * open the sockets.
  921. X */
  922. X#undef NFS_HACK
  923. X
  924. X/*
  925. X * By default screen will create a directory named ".screen" in the user's
  926. X * HOME directory to contain the named sockets.  If this causes you problems
  927. X * (e.g. some user's HOME directories are NFS-mounted and don't support
  928. X * named sockets) you can have screen create the socket directories in a
  929. X * common subdirectory, such as /tmp or /usr/tmp.  It makes things a little
  930. X * more secure if you choose a directory where the "sticky" bit is on, but
  931. X * this isn't required.  Screen will name the subdirectories "S-$USER"
  932. X * (e.g /tmp/S-davison).
  933. X * Do not define TMPTEST unless it's for debugging purpose.
  934. X * If you want to have your socket directory in "/tmp/screens" then
  935. X * define LOCALSOCKDIR and change the definition of SOCKDIR below.
  936. X */
  937. X#undef LOCALSOCKDIR
  938. X
  939. X#ifdef LOCALSOCKDIR
  940. X# ifndef TMPTEST
  941. X#  define SOCKDIR "/local/screens"
  942. X# else
  943. X#  define SOCKDIR "/tmp/screens"
  944. X# endif
  945. X#endif
  946. X
  947. X/*
  948. X * Define USEBCOPY if the bcopy() from your system's C library supports the
  949. X * overlapping of source and destination blocks.  When undefined, screen
  950. X * uses its own (probably slower) version of bcopy().
  951. X */
  952. X#define USEBCOPY
  953. X
  954. X/*
  955. X * If you'd rather see the status line on the first line of your
  956. X * terminal rather than the last, define TOPSTAT.
  957. X */
  958. X#undef TOPSTAT
  959. X
  960. X/*
  961. X * If your system has vsprintf() and requires the use of the macros in
  962. X * "varargs.h" to use functions with variable arguments,
  963. X * define USEVARARGS.
  964. X */
  965. X#undef USEVARARGS
  966. X
  967. X/*
  968. X * Define this if your system supports named pipes.
  969. X */
  970. X#undef NAMEDPIPE
  971. X
  972. X/*
  973. X * here come the erlangen extensions to screen:
  974. X * define LOCK if you want to use a lock program for a screenlock.
  975. X * define PASSWORD for secure reattach of your screen.
  976. X * define COPY_PASTE to use the famous hacker's treasure zoo.
  977. X * define POW_DETACH to have a detach_and_logout key.
  978. X * define REMOTE_DETACH (-d option) to move screen between terminals.
  979. X * (jw)
  980. X */
  981. X#define LOCK
  982. X#define PASSWORD
  983. X#define COPY_PASTE
  984. X#define REMOTE_DETACH
  985. X#define POW_DETACH
  986. X
  987. X/*
  988. X * As error messages are mostly meaningless to the user, we
  989. X * try to throw out phrases that are somewhat more familiar
  990. X * to ...well, at least familiar to us NetHack players.
  991. X */
  992. X#define NETHACK
  993. X
  994. X/*
  995. X * and another sneaky feature: screen sources two startup files.
  996. X * first a global file with a path specified here, second
  997. X * your local $HOME/.screenrc
  998. X * Don't define this, if you don't want it.
  999. X */
  1000. X#undef ETCSCREENRC "/local/etc/screenrc"
  1001. X
  1002. X/*
  1003. X *    End of User Configuration Section
  1004. X */
  1005. END_OF_FILE
  1006. if test 14876 -ne `wc -c <'config/config.gould_np1'`; then
  1007.     echo shar: \"'config/config.gould_np1'\" unpacked with wrong size!
  1008. fi
  1009. # end of 'config/config.gould_np1'
  1010. fi
  1011. if test -f 'help.c' -a "${1}" != "-c" ; then 
  1012.   echo shar: Will not clobber existing file \"'help.c'\"
  1013. else
  1014. echo shar: Extracting \"'help.c'\" \(12910 characters\)
  1015. sed "s/^X//" >'help.c' <<'END_OF_FILE'
  1016. X/* Copyright (c) 1991
  1017. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  1018. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  1019. X * Copyright (c) 1987 Oliver Laumann
  1020. X *
  1021. X * This program is free software; you can redistribute it and/or modify
  1022. X * it under the terms of the GNU General Public License as published by
  1023. X * the Free Software Foundation; either version 1, or (at your option)
  1024. X * any later version.
  1025. X *
  1026. X * This program is distributed in the hope that it will be useful,
  1027. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1028. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1029. X * GNU General Public License for more details.
  1030. X *
  1031. X * You should have received a copy of the GNU General Public License
  1032. X * along with this program (see the file COPYING); if not, write to the
  1033. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1034. X *
  1035. X * Noteworthy contributors to screen's design and implementation:
  1036. X *    Wayne Davison (davison@borland.com)
  1037. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  1038. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  1039. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  1040. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  1041. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  1042. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  1043. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  1044. X *    Marc Boucher (marc@CAM.ORG)
  1045. X *
  1046. X ****************************************************************
  1047. X */
  1048. X
  1049. X#ifndef lint
  1050. X  static char rcs_id[] = "$Id: help.c,v 1.42 91/10/11 11:42:09 jnweiger Exp $ FAU";
  1051. X#endif
  1052. X
  1053. X#include "config.h"
  1054. X#include <stdio.h>
  1055. X#include <sys/types.h>
  1056. X#if defined(BSD) || defined(sequent) || defined(pyr)
  1057. X# include <strings.h>
  1058. X#else
  1059. X# include <string.h>
  1060. X#endif
  1061. X
  1062. X#include "screen.h"
  1063. X#include "ansi.h"
  1064. X#include "extern.h"
  1065. X#include "patchlevel.h"
  1066. X
  1067. int help_page = 0;
  1068. int command_search, command_bindings = 0;
  1069. extern char Esc, MetaEsc;
  1070. extern char *KeyNames[];
  1071. extern struct key ktab[];
  1072. extern int screenwidth, screenheight;
  1073. extern char *blank, *null, *CE;
  1074. extern struct win *fore;
  1075. X
  1076. static void centerline __P((char *));
  1077. static void HelpRedisplayLine __P((int, int, int, int));
  1078. static void process_help_input __P((char **, int *));
  1079. static void AbortHelp __P((void));
  1080. static void add_key_to_buf __P((char *, int));
  1081. X
  1082. void
  1083. exit_with_usage(myname)
  1084. char *myname;
  1085. X{
  1086. X  printf("Use: %s [-opts] [cmd [args]]\n", myname);
  1087. X  printf(" or: %s -r [host.tty]\n\nOptions:\n", myname);
  1088. X  printf("-a           Force all capabilities into each window's termcap\n");
  1089. X  printf("-A -[r|R]    Adapt all windows to the new display width & height\n");
  1090. X  printf("-c file      Read configuration file instead of .screenrc\n");
  1091. X#ifdef REMOTE_DETACH
  1092. X  printf("-d (-r)      Detach the elsewhere running screen (and reattach here)\n");
  1093. X  printf("-D (-r)      Detach and logout remote (and reattach here)\n");
  1094. X#endif
  1095. X  printf("-e xy        Change command characters\n");
  1096. X  printf("-f           Flow control on, -fn = off, -fa = auto\n");
  1097. X  printf("-h lines     Set the size of the scrollback history buffer\n");
  1098. X  printf("-i           Interrupt output sooner when flow control is on\n");
  1099. X  printf("-l           Login mode on (update /etc/utmp), -ln = off\n");
  1100. X  printf("-list        or -ls. Do nothing, just list our SockDir\n");
  1101. X  printf("-L           Terminal's last character can be safely updated\n");
  1102. X  printf("-O           Choose optimal output rather than exact vt100 emulation\n");
  1103. X  printf("-q           Quiet startup. Sets $status if unsuccessful.\n");
  1104. X  printf("-r           Reattach to a detached screen process\n");
  1105. X  printf("-R           Reattach if possible, otherwise start a new session\n");
  1106. X  printf("-s shell     Shell to execute rather than $SHELL\n");
  1107. X  printf("-T term      Use term as $TERM for windows, rather than \"screen\"\n");
  1108. X  printf("-t title     Set command's a.k.a. (window title)\n");
  1109. X  printf("-wipe        Do nothing, just clean up SockDir\n");
  1110. X  exit(1);
  1111. X}
  1112. X
  1113. X/* Esc-char is not consumed. All others are. Esc-char, space, and return end */
  1114. static void
  1115. process_help_input(ppbuf, plen)
  1116. char **ppbuf;
  1117. int *plen;
  1118. X{
  1119. X  int done = 0;
  1120. X
  1121. X  if (ppbuf == 0)
  1122. X    {
  1123. X      AbortHelp();
  1124. X      return;
  1125. X    }
  1126. X  while (!done && *plen > 0)
  1127. X    {
  1128. X      switch (**ppbuf)
  1129. X    {
  1130. X    case ' ':
  1131. X      if (display_help() == 0)
  1132. X            break;
  1133. X      /* FALLTHROUGH */
  1134. X    case '\r':
  1135. X    case '\n':
  1136. X      done = 1;
  1137. X      break;
  1138. X    default:
  1139. X      if (**ppbuf == Esc)
  1140. X        {
  1141. X          done = 1;
  1142. X          continue;
  1143. X        }
  1144. X      break;
  1145. X    }
  1146. X      ++*ppbuf;
  1147. X      --*plen;
  1148. X    }
  1149. X  if (done)
  1150. X    AbortHelp();
  1151. X}
  1152. X
  1153. static void
  1154. AbortHelp()
  1155. X{
  1156. X  help_page = 0;
  1157. X  ExitOverlayPage();
  1158. X  Activate();
  1159. X}
  1160. X
  1161. static int maxrow, grow, numcols, numrows, num_names;
  1162. static int numskip, numpages;
  1163. X
  1164. int
  1165. display_help()
  1166. X{
  1167. X  int col, crow, n, key = 0;
  1168. X  enum keytype typ = ktab[0].type;
  1169. X  char buf[256], Esc_buf[5], cbuf[256];
  1170. X
  1171. X  if (!help_page++)
  1172. X    {
  1173. X      if (screenwidth < 26 || screenheight < 6)
  1174. X        {
  1175. X      Msg(0, "Window size too small for help page");
  1176. X      help_page = 0;
  1177. X      return -1;
  1178. X        }
  1179. X      InitOverlayPage(process_help_input, HelpRedisplayLine, 0, 0);
  1180. X
  1181. X      command_bindings = 0;
  1182. X      for (key = 0; key < 256; key++)
  1183. X        if ((typ = ktab[key].type) == KEY_CREATE
  1184. X        || typ == KEY_SCREEN
  1185. X        || typ == KEY_SET
  1186. X        || (typ == KEY_AKA && ktab[key].args))
  1187. X      command_bindings++;
  1188. X      debug1("help: command_bindings counted: %d\n",command_bindings);
  1189. X      for (n = 0; KeyNames[n] != NULL; n++)
  1190. X    ; /* we dont know "sizeof * KeyNames" */
  1191. X      num_names = n - 1;
  1192. X      debug1("help: we find %d named keys (+1).\n", num_names);
  1193. X      command_search = 0;
  1194. X
  1195. X      numcols = screenwidth/26;
  1196. X      if (numcols == 0)
  1197. X        numcols = 1;
  1198. X      numrows = (num_names + numcols -1) / numcols;
  1199. X      debug1("Numrows: %d\n", numrows);
  1200. X      numskip = screenheight-5 - (2 + numrows);
  1201. X      while (numskip < 0)
  1202. X    numskip += screenheight-5;
  1203. X      numskip %= screenheight-5;
  1204. X      debug1("Numskip: %d\n", numskip);
  1205. X      if (numskip > screenheight/3 || numskip > command_bindings)
  1206. X    numskip = 1;
  1207. X      maxrow = 2 + numrows + numskip + command_bindings;
  1208. X      grow = 0;
  1209. X
  1210. X      numpages = (maxrow + screenheight-6) / (screenheight-5);
  1211. X    }
  1212. X
  1213. X  if (grow >= maxrow)
  1214. X    { 
  1215. X      return(-1);
  1216. X    }
  1217. X
  1218. X  /* Clear the help screen */
  1219. X  ClearDisplay();
  1220. X  
  1221. X  sprintf(cbuf,"Screen key bindings, page %d of %d.", help_page, numpages);
  1222. X  centerline(cbuf);
  1223. X  printf("\n");
  1224. X  crow = 2;
  1225. X
  1226. X  *Esc_buf = '\0';
  1227. X  add_key_to_buf(Esc_buf, Esc);
  1228. X  Esc_buf[strlen(Esc_buf) - 1] = '\0';
  1229. X
  1230. X  for (; crow < screenheight - 3; crow++)
  1231. X    {
  1232. X      if (grow < 1)
  1233. X        {
  1234. X         *buf = '\0';
  1235. X          add_key_to_buf(buf, MetaEsc);
  1236. X          buf[strlen(buf) - 1] = '\0';
  1237. X          sprintf(cbuf,"Command key:  %s   Literal %s:  %s", Esc_buf, Esc_buf, buf);
  1238. X          centerline(cbuf);
  1239. X      grow++;
  1240. X        }
  1241. X      else if (grow >= 2 && grow-2 < numrows)
  1242. X    {
  1243. X      for (col = 0; col < numcols && (n = numrows * col + (grow-2)) < num_names; col++)
  1244. X        {
  1245. X          debug1("help: searching key %d\n", n);
  1246. X          buf[0] = '\0';
  1247. X          for (key = 0; key < 128; key++)
  1248. X        if (ktab[key].type == (enum keytype) (n + 2)
  1249. X            && ((enum keytype) (n + 2) != KEY_AKA || !ktab[key].args) )
  1250. X          add_key_to_buf(buf, key);
  1251. X          buf[14] = '\0';
  1252. X          /*
  1253. X           * Format is up to 10 chars of name, 1 spaces, 14 chars of key
  1254. X           * bindings, and a space.
  1255. X           */
  1256. X          printf("%-10.10s %-14.14s ", KeyNames[n + 1], buf);
  1257. X        }
  1258. X      printf("\r\n");
  1259. X          grow++;
  1260. X        }
  1261. X      else if (grow-2-numrows >= numskip 
  1262. X               && grow-2-numrows-numskip < command_bindings)
  1263. X        {
  1264. X          char **pp, *cp;
  1265. X
  1266. X      while (command_search < 128
  1267. X         && (typ = ktab[command_search].type) != KEY_CREATE
  1268. X         && typ != KEY_SCREEN
  1269. X         && typ != KEY_SET
  1270. X         && (typ != KEY_AKA || !ktab[command_search].args))
  1271. X        command_search++;
  1272. X      buf[0] = '\0';
  1273. X      add_key_to_buf(buf, command_search);
  1274. X      printf("%-4s", buf);
  1275. X      col = 4;
  1276. X      if (typ != KEY_CREATE)
  1277. X        {
  1278. X          col += strlen(KeyNames[(int)typ - 1]) + 1;
  1279. X          printf("%s ", KeyNames[(int)typ - 1]);
  1280. X        }
  1281. X      pp = ktab[command_search++].args;
  1282. X      while (pp && (cp = *pp) != NULL)
  1283. X        {
  1284. X          if (!*cp || (index(cp, ' ') != NULL))
  1285. X        {
  1286. X          if (index(cp, '\'') != NULL)
  1287. X            *buf = '"';
  1288. X          else
  1289. X            *buf = '\'';
  1290. X          sprintf(buf + 1, "%s%c", cp, *buf);
  1291. X          cp = buf;
  1292. X        }
  1293. X          if ((col += (unsigned)strlen(cp) + 1) >= screenwidth)
  1294. X        {
  1295. X          col = screenwidth - (col - (strlen(cp) + 1)) - 2;
  1296. X          if (col >= 0)
  1297. X            {
  1298. X              n = cp[col];
  1299. X              cp[col] = '\0';
  1300. X              printf("%s$", *pp);
  1301. X              cp[col] = (char) n;
  1302. X              }
  1303. X              break;
  1304. X            }
  1305. X          printf("%s%c", cp, (screenwidth - col != 1 || !pp[1]) ? ' ' : '$');
  1306. X          pp++;
  1307. X        }
  1308. X      printf("\r\n");
  1309. X      grow++;
  1310. X    }
  1311. X      else
  1312. X    {
  1313. X          putchar('\n');
  1314. X      grow++;
  1315. X    }
  1316. X    }
  1317. X  printf("\n");
  1318. X  sprintf(cbuf,"[Press Space %s Return to end; %s to begin a command.]",
  1319. X     grow < maxrow ? "for next page;" : "or", Esc_buf);
  1320. X  centerline(cbuf);
  1321. X  fflush(stdout);
  1322. X  SetLastPos(0, screenheight-1);
  1323. X  return(0);
  1324. X}
  1325. X
  1326. static void
  1327. add_key_to_buf(buf, key)
  1328. char *buf;
  1329. int key;
  1330. X{
  1331. X  debug1("help: key found: %c\n", key);
  1332. X  switch (key)
  1333. X    {
  1334. X    case ' ':
  1335. X      strcat(buf, "sp ");
  1336. X      break;
  1337. X    case 0x7f:
  1338. X      strcat(buf, "^? ");
  1339. X      break;
  1340. X    default:
  1341. X      if (key < ' ')
  1342. X    sprintf(buf + strlen(buf), "^%c ", (key | 0x40));
  1343. X      else
  1344. X    sprintf(buf + strlen(buf), "%c ", key);
  1345. X      break;
  1346. X    }
  1347. X}
  1348. X
  1349. static void
  1350. centerline(str)
  1351. char *str;
  1352. X{
  1353. X  int l;
  1354. X  l = (screenwidth - 1 + (unsigned)strlen(str)) / 2;
  1355. X  if (l > screenwidth - 1)
  1356. X    l = screenwidth - 1;
  1357. X  printf("%*.*s\r\n", l, l, str);
  1358. X}
  1359. X
  1360. static void
  1361. HelpRedisplayLine(y, xs, xe, isblank)
  1362. int y, xs, xe, isblank;
  1363. X{
  1364. X  if (isblank)
  1365. X    return;
  1366. X  if (CE)
  1367. X    {
  1368. X      GotoPos(xs, y);
  1369. X      PutStr(CE);
  1370. X      return;
  1371. X    }
  1372. X  DisplayLine(null, null, null, blank, null, null, y, xs, xe);
  1373. X}
  1374. X
  1375. X/*
  1376. X * here all the copyright stuff 
  1377. X */
  1378. X
  1379. X
  1380. static char version[40];
  1381. X
  1382. static char cpmsg[] = "\
  1383. X\n\
  1384. iScreen version %v\n\
  1385. X\n\
  1386. Copyright (c) 1991\n\
  1387. X    Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)\n\
  1388. X    Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)\n\
  1389. Copyright (c) 1987 Oliver Laumann\n\
  1390. X\n\
  1391. This program is free software; you can redistribute it and/or \
  1392. modify it under the terms of the GNU General Public License as published \
  1393. by the Free Software Foundation; either version 1, or (at your option) \
  1394. any later version.\n\
  1395. X\n\
  1396. This program is distributed in the hope that it will be useful, \
  1397. but WITHOUT ANY WARRANTY; without even the implied warranty of \
  1398. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \
  1399. GNU General Public License for more details.\n\
  1400. X\n\
  1401. You should have received a copy of the GNU General Public License \
  1402. along with this program (see the file COPYING); if not, write to the \
  1403. XFree Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";
  1404. X
  1405. X
  1406. static void process_copyright_input __P((char **, int *));
  1407. static void AbortCopyright __P((void));
  1408. static void copypage __P((void));
  1409. X
  1410. static char *cps, *savedcps;
  1411. X
  1412. static void
  1413. process_copyright_input(ppbuf, plen)
  1414. char **ppbuf;
  1415. int *plen;
  1416. X{
  1417. X  int done = 0;
  1418. X
  1419. X  if (ppbuf == 0)
  1420. X    {
  1421. X      AbortCopyright();
  1422. X      return;
  1423. X    }
  1424. X  while (!done && *plen > 0)
  1425. X    {
  1426. X      switch (**ppbuf)
  1427. X    {
  1428. X    case ' ':
  1429. X          if (*cps)
  1430. X        {
  1431. X          copypage();
  1432. X          break;
  1433. X        }
  1434. X      /* FALLTHROUGH */
  1435. X    case '\r':
  1436. X    case '\n':
  1437. X      AbortCopyright();
  1438. X      done = 1;
  1439. X      break;
  1440. X    default:
  1441. X      break;
  1442. X    }
  1443. X      ++*ppbuf;
  1444. X      --*plen;
  1445. X    }
  1446. X}
  1447. X
  1448. static void
  1449. AbortCopyright()
  1450. X{
  1451. X  ExitOverlayPage();
  1452. X  Activate();
  1453. X}
  1454. X
  1455. void
  1456. display_copyright()
  1457. X{
  1458. X  if (screenwidth < 10 || screenheight < 5)
  1459. X    {
  1460. X      Msg(0, "Window size too small for copyright page");
  1461. X      return;
  1462. X    }
  1463. X  InitOverlayPage(process_copyright_input, HelpRedisplayLine, 0, 0);
  1464. X  sprintf(version, "%d.%.2d.%.2d%s (%s) %s", REV, VERS, PATCHLEVEL, STATE, ORIGIN, DATE);
  1465. X  cps = cpmsg;
  1466. X  savedcps = 0;
  1467. X  copypage();
  1468. X}
  1469. X
  1470. X
  1471. static void
  1472. copypage()
  1473. X{
  1474. X  char *ws;
  1475. X  int x, y, l;
  1476. X  char cbuf[80];
  1477. X
  1478. X  ClearDisplay();
  1479. X  x = y = 0;
  1480. X  while(*cps)
  1481. X    {
  1482. X      ws = cps;
  1483. X      while (*cps == ' ')
  1484. X    cps++;
  1485. X      if (strncmp(cps, "%v", 2) == 0)
  1486. X    {
  1487. X      savedcps = cps + 2;
  1488. X      ws = cps = version;
  1489. X    }
  1490. X      while (*cps && *cps != ' ' && *cps != '\n')
  1491. X    cps++;
  1492. X      l = cps - ws;
  1493. X      cps = ws;
  1494. X      if (l > screenwidth - 1)
  1495. X    l = screenwidth - 1;
  1496. X      if (x && x + l >= screenwidth - 2)
  1497. X    {
  1498. X      printf("\r\n");
  1499. X      x = 0;
  1500. X      if (++y > screenheight - 4)
  1501. X            break;
  1502. X    }
  1503. X      if (x)
  1504. X    {
  1505. X      putchar(' ');
  1506. X      x++;
  1507. X    }
  1508. X      printf("%*.*s", l, l, ws);
  1509. X      x += l;
  1510. X      cps += l;
  1511. X      if (*cps == 0 && savedcps)
  1512. X    {
  1513. X      cps = savedcps;
  1514. X      savedcps = 0;
  1515. X    }
  1516. X      if (*cps == '\n')
  1517. X    {
  1518. X      printf("\r\n");
  1519. X      x = 0;
  1520. X      if (++y > screenheight - 4)
  1521. X            break;
  1522. X    }
  1523. X      if (*cps == ' ' || *cps == '\n')
  1524. X    cps++;
  1525. X    }
  1526. X  while (y++ < screenheight - 2)
  1527. X    printf("\r\n");
  1528. X  sprintf(cbuf,"[Press Space %s Return to end.]",
  1529. X     *cps ? "for next page;" : "or");
  1530. X  centerline(cbuf);
  1531. X  fflush(stdout);
  1532. X  SetLastPos(0, screenheight-1);
  1533. X}
  1534. X  
  1535. END_OF_FILE
  1536. if test 12910 -ne `wc -c <'help.c'`; then
  1537.     echo shar: \"'help.c'\" unpacked with wrong size!
  1538. fi
  1539. # end of 'help.c'
  1540. fi
  1541. if test -f 'screen.h' -a "${1}" != "-c" ; then 
  1542.   echo shar: Will not clobber existing file \"'screen.h'\"
  1543. else
  1544. echo shar: Extracting \"'screen.h'\" \(10535 characters\)
  1545. sed "s/^X//" >'screen.h' <<'END_OF_FILE'
  1546. X/* Copyright (c) 1991
  1547. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  1548. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  1549. X * Copyright (c) 1987 Oliver Laumann
  1550. X *
  1551. X * This program is free software; you can redistribute it and/or modify
  1552. X * it under the terms of the GNU General Public License as published by
  1553. X * the Free Software Foundation; either version 1, or (at your option)
  1554. X * any later version.
  1555. X *
  1556. X * This program is distributed in the hope that it will be useful,
  1557. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1558. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1559. X * GNU General Public License for more details.
  1560. X *
  1561. X * You should have received a copy of the GNU General Public License
  1562. X * along with this program (see the file COPYING); if not, write to the
  1563. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1564. X *
  1565. X * Noteworthy contributors to screen's design and implementation:
  1566. X *    Wayne Davison (davison@borland.com)
  1567. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  1568. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  1569. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  1570. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  1571. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  1572. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  1573. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  1574. X *    Marc Boucher (marc@CAM.ORG)
  1575. X *
  1576. X ****************************************************************
  1577. X * $Id: screen.h,v 1.49 91/10/11 10:24:11 jnweiger Exp $ FAU
  1578. X */
  1579. X
  1580. X/* screen.h now includes enough to satisfy its own references.
  1581. X * only config.h is still needed.
  1582. X */
  1583. X
  1584. X#include <stdio.h>
  1585. X#include <errno.h>
  1586. X#if defined(pyr)
  1587. extern int errno;
  1588. X#endif
  1589. X
  1590. X#ifdef sun
  1591. X# define getpgrp __getpgrp
  1592. X# define exit __exit
  1593. X#endif
  1594. X
  1595. X#ifdef POSIX
  1596. X#include <unistd.h>
  1597. X# if defined(__STDC__)
  1598. X#  include <stdlib.h>
  1599. X# endif
  1600. X#endif
  1601. X
  1602. X#ifdef sun
  1603. X# undef getpgrp
  1604. X# undef exit
  1605. X#endif
  1606. X
  1607. X#ifdef POSIX
  1608. X# include <termios.h>
  1609. X# ifdef hpux
  1610. X#  include <bsdtty.h>
  1611. X# endif
  1612. X#else
  1613. X# ifdef TERMIO
  1614. X#  include <termio.h>
  1615. X# else
  1616. X#  include <sgtty.h>
  1617. X# endif /* TERMIO */
  1618. X#endif /* POSIX */
  1619. X
  1620. X#ifdef SUIDROOT
  1621. X#  ifdef LOCKPTY
  1622. X#     undef LOCKPTY
  1623. X#  endif
  1624. X#endif
  1625. X
  1626. X#ifndef UTMPOK
  1627. X#  ifdef USRLIMIT
  1628. X#     undef USRLIMIT
  1629. X#  endif
  1630. X#endif
  1631. X
  1632. X#ifndef LOGINDEFAULT
  1633. X#  define LOGINDEFAULT 0
  1634. X#endif
  1635. X
  1636. X#if defined(LOADAV_3DOUBLES) || defined(LOADAV_3LONGS) || defined(LOADAV_4LONGS)
  1637. X#  define LOADAV
  1638. X#endif
  1639. X
  1640. X#ifndef FSCALE
  1641. X# ifdef MIPS
  1642. X#  define FSCALE 256            /* MIPS doesn't, and... */
  1643. X# else
  1644. X#  define FSCALE 1000.0     /* Sequent doesn't define FSCALE...grrrr */
  1645. X# endif    
  1646. X#endif
  1647. X
  1648. X#ifndef F_OK
  1649. X#define F_OK 0
  1650. X#endif
  1651. X#ifndef X_OK
  1652. X#define X_OK 1
  1653. X#endif
  1654. X#ifndef W_OK
  1655. X#define W_OK 2
  1656. X#endif
  1657. X#ifndef R_OK
  1658. X#define R_OK 4
  1659. X#endif
  1660. X
  1661. X#ifndef MAXPATH
  1662. X# define MAXPATH 1024
  1663. X#endif
  1664. X
  1665. X#ifdef SIGVOID
  1666. X# if defined(ultrix)
  1667. X#  define sig_t void
  1668. X# else /* nice compilers: */
  1669. X   typedef void sig_t;
  1670. X# endif
  1671. X#else
  1672. X   typedef int sig_t;
  1673. X#endif
  1674. X
  1675. X#ifdef SVR4
  1676. X#define SIGPROTOARG   (int)
  1677. X#define SIGDEFARG     int sigsig
  1678. X#define SIGARG        0
  1679. X#else
  1680. X#define SIGPROTOARG   (void)
  1681. X#define SIGDEFARG
  1682. X#define SIGARG
  1683. X#endif
  1684. X
  1685. X#if (!defined(SYSV) && !defined(POSIX)) || defined(sysV68)
  1686. typedef int pid_t;
  1687. X#endif
  1688. X
  1689. X#if defined(M_XENIX)
  1690. typedef int pid_t;
  1691. typedef int gid_t;
  1692. typedef int uid_t;
  1693. X#endif
  1694. X
  1695. X#if defined(UTMPOK) && defined(_SEQUENT_)
  1696. X# define GETUTENT
  1697. X#endif
  1698. X
  1699. X#ifdef GETUTENT
  1700. X  typedef char *slot_t;
  1701. X#else
  1702. X  typedef int slot_t;
  1703. X#endif
  1704. X
  1705. X#if !defined(BSD) && !defined(sequent)
  1706. X# define index strchr
  1707. X# define rindex strrchr
  1708. X#endif
  1709. X
  1710. X#ifdef SYSV /* jw. */
  1711. X# define bzero(poi,len) memset(poi,0,len)
  1712. X# define killpg(pgrp,sig) kill( -(pgrp), sig)
  1713. X#endif
  1714. X
  1715. X/* here comes my own Free: jw. */
  1716. X#define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
  1717. X
  1718. X#define Ctrl(c) ((c)&037)
  1719. X
  1720. X/* modes for markroutine 
  1721. X */
  1722. X#define PLAIN 0
  1723. X#define TRICKY 1
  1724. X
  1725. X/*typedef long off_t; */    /* Someone might need this */
  1726. X
  1727. enum state_t 
  1728. X{
  1729. X  LIT,                /* Literal input */
  1730. X  ESC,                /* Start of escape sequence */
  1731. X  ASTR,                /* Start of control string */
  1732. X  STRESC,            /* ESC seen in control string */
  1733. X  CSI,                /* Reading arguments in "CSI Pn ; Pn ; ... ; XXX" */
  1734. X  PRIN,                /* Printer mode */
  1735. X  PRINESC,            /* ESC seen in printer mode */
  1736. X  PRINCSI,            /* CSI seen in printer mode */
  1737. X  PRIN4            /* CSI 4 seen in printer mode */
  1738. X};
  1739. X
  1740. enum string_t 
  1741. X{
  1742. X  NONE,
  1743. X  DCS,                /* Device control string */
  1744. X  OSC,                /* Operating system command */
  1745. X  APC,                /* Application program command */
  1746. X  PM,                /* Privacy message */
  1747. X  AKA                /* a.k.a. for current screen */
  1748. X};
  1749. X
  1750. X#define MAXSTR        256
  1751. X#define MAXARGS     64
  1752. X#define MSGWAIT     5
  1753. X#define MSGMINWAIT     1
  1754. X
  1755. X/* 
  1756. X * 4 <= IOSIZE <=1000
  1757. X * you may try to vary this value. Use low values if your (VMS) system
  1758. X * tends to choke when pasting. Use high values if you want to test
  1759. X * how many characters your pty's can buffer.
  1760. X */
  1761. X#define IOSIZE        80
  1762. X
  1763. X/*
  1764. X * if a nasty user really wants to try a history of 2000 lines on all 10
  1765. X * windows, he will allocate 5 MegaBytes of memory, which is quite enough.
  1766. X */
  1767. X#define MAXHISTHEIGHT 2000
  1768. X#define DEFAULTHISTHEIGHT 50
  1769. X
  1770. struct win 
  1771. X{
  1772. X  int wpid; /* process, that is connected to the other end of ptyfd */
  1773. X  int ptyfd; /* usually the master side of our pty pair */
  1774. X  int ttyflag; /* 1 if ptyfd is connected to a user specified tty. */
  1775. X  int aflag;
  1776. X  char outbuf[IOSIZE];
  1777. X  int outlen;
  1778. X  int autoaka, akapos;
  1779. X  char cmd[MAXSTR];
  1780. X  char tty[MAXSTR];
  1781. X  int args[MAXARGS];
  1782. X  int NumArgs;
  1783. X  slot_t slot;
  1784. X  char **image;
  1785. X  char **attr;
  1786. X  char **font;
  1787. X  int LocalCharset;
  1788. X  int charsets[4];
  1789. X  int ss;
  1790. X  int active;
  1791. X  int x, y;
  1792. X  char LocalAttr;
  1793. X  int saved;
  1794. X  int Saved_x, Saved_y;
  1795. X  char SavedLocalAttr;
  1796. X  int SavedLocalCharset;
  1797. X  int SavedCharsets[4];
  1798. X  int top, bot;
  1799. X  int wrap;
  1800. X  int origin;
  1801. X  int insert;
  1802. X  int keypad;
  1803. X  int width, height;    /* width AND height, as we have now resized wins. jw.*/
  1804. X  int histheight;       /* all histbases are malloced with width * histheight */
  1805. X  int histidx;          /* 0= < histidx < histheight; where we insert lines */
  1806. X  char **ihist;     /* the history buffer  image */
  1807. X  char **ahist;     /* attributes */
  1808. X  char **fhist;     /* fonts */
  1809. X  enum state_t state;
  1810. X  enum string_t StringType;
  1811. X  char string[MAXSTR];
  1812. X  char *stringp;
  1813. X  char *tabs;
  1814. X  int vbwait;            
  1815. X  int bell;
  1816. X  int flow;
  1817. X  int autoflow;
  1818. X  int WinLink;
  1819. X  FILE *logfp;
  1820. X  int monitor;
  1821. X  int cursor_invisible;
  1822. X};
  1823. X
  1824. X#define D_DETACH    0
  1825. X#define D_STOP        1
  1826. X#define D_REMOTE    2
  1827. X#define D_POWER     3
  1828. X#define D_REMOTE_POWER    4
  1829. X#define D_LOCK        5
  1830. X
  1831. X/*
  1832. X * Here are the messages the attacher sends to the backend
  1833. X */
  1834. X
  1835. X#define MSG_CREATE    0
  1836. X#define MSG_ERROR    1
  1837. X#define MSG_ATTACH    2
  1838. X#define MSG_CONT    3
  1839. X#define MSG_DETACH    4
  1840. X#define MSG_POW_DETACH    5
  1841. X#define MSG_WINCH    6
  1842. X#define MSG_HANGUP    7
  1843. X
  1844. struct msg
  1845. X{
  1846. X  int type;
  1847. X  union
  1848. X    {
  1849. X      struct
  1850. X    {
  1851. X      int lflag;
  1852. X      int aflag;
  1853. X      int flowflag;
  1854. X      int hheight;  /* size of scrollback buffer */
  1855. X      int nargs;
  1856. X      char line[MAXPATH];
  1857. X      char dir[MAXPATH];
  1858. X      char screenterm[20]; /* is screen really "screen" ? */
  1859. X    }
  1860. X      create;
  1861. X      struct
  1862. X    {
  1863. X      int apid;
  1864. X      int adaptflag; /* do we wish to adapt window size? */
  1865. X      int lines, columns;
  1866. X      char tty[MAXPATH];
  1867. X      char password[20];
  1868. X      char envterm[MAXPATH];
  1869. X    }
  1870. X      attach;
  1871. X      struct 
  1872. X    {
  1873. X      char password[20];
  1874. X      int dpid;
  1875. X      char tty[MAXPATH];
  1876. X    }
  1877. X      detach;
  1878. X      char message[MAXPATH*2];
  1879. X    } m;
  1880. X};
  1881. X
  1882. X/*
  1883. X * And the signals the attacher receives from the backend
  1884. X */
  1885. X
  1886. X#define SIG_BYE        SIGHUP
  1887. X#define SIG_POWER_BYE    SIGUSR1
  1888. X#define SIG_LOCK    SIGUSR2
  1889. X#define SIG_STOP    SIGTSTP
  1890. X#define SIG_PW_OK    SIGUSR1
  1891. X#define SIG_PW_FAIL    SIG_BYE
  1892. X
  1893. X
  1894. struct mode
  1895. X{
  1896. X#ifdef TIOCSWINSZ
  1897. X  struct winsize ws;
  1898. X#endif
  1899. X#ifdef POSIX
  1900. X  struct termios tio;
  1901. X# ifdef hpux
  1902. X  struct ltchars m_ltchars;
  1903. X# endif
  1904. X#else
  1905. X# ifdef TERMIO
  1906. X  struct termio tio;
  1907. X# else
  1908. X  struct sgttyb m_ttyb;
  1909. X  struct tchars m_tchars;
  1910. X  struct ltchars m_ltchars;
  1911. X  int m_ldisc;
  1912. X  int m_lmode;
  1913. X# endif                /* TERMIO */
  1914. X#endif                /* POSIX */
  1915. X};
  1916. X
  1917. X#define BELL        7
  1918. X#define VBELLWAIT    1 /* No. of seconds a vbell will be displayed */
  1919. X
  1920. X#define BELL_OFF    0 /* No bell has occurred in the window */
  1921. X#define BELL_ON     1 /* A bell has occurred, but user not yet notified */
  1922. X#define BELL_DONE    2 /* A bell has occured, user has been notified */
  1923. X#define BELL_VISUAL     3 /* A bell has occured in fore win, notify him visually */
  1924. X
  1925. X#define MON_OFF     0 /* Monitoring is off in the window */
  1926. X#define MON_ON        1 /* No activity has occurred in the window */
  1927. X#define MON_FOUND    2 /* Activity has occured, but user not yet notified */
  1928. X#define MON_DONE    3 /* Activity has occured, user has been notified */
  1929. X
  1930. X#define DUMP_TERMCAP    0 /* WriteFile() options */
  1931. X#define DUMP_HARDCOPY    1
  1932. X#define DUMP_EXCHANGE    2
  1933. X
  1934. X#undef MAXWIN20
  1935. X
  1936. X#ifdef MAXWIN20
  1937. X#define MAXWIN    20
  1938. X#else
  1939. X#define MAXWIN    10
  1940. X#endif
  1941. X
  1942. X/* the key definitions are used in screen.c and help.c */
  1943. X/* keep this list synchronus with the names given in fileio.c */
  1944. enum keytype
  1945. X{
  1946. X  KEY_IGNORE, /* Keep these first 2 at the start */
  1947. X  KEY_SCREEN,
  1948. X  KEY_0,  KEY_1,  KEY_2,  KEY_3,  KEY_4,
  1949. X  KEY_5,  KEY_6,  KEY_7,  KEY_8,  KEY_9,
  1950. X#ifdef MAXWIN20
  1951. X  KEY_10, KEY_11, KEY_12, KEY_13, KEY_14,
  1952. X  KEY_15, KEY_16, KEY_17, KEY_18, KEY_19,
  1953. X#endif
  1954. X  KEY_AKA,
  1955. X  KEY_AUTOFLOW,
  1956. X  KEY_CLEAR,
  1957. X  KEY_COLON,
  1958. X  KEY_COPY,
  1959. X  KEY_DETACH,
  1960. X  KEY_FLOW,
  1961. X  KEY_HARDCOPY,
  1962. X  KEY_HELP,
  1963. X  KEY_HISTORY,
  1964. X  KEY_INFO,
  1965. X  KEY_KILL,
  1966. X  KEY_LASTMSG,
  1967. X  KEY_LICENSE,
  1968. X  KEY_LOCK,
  1969. X  KEY_LOGTOGGLE,
  1970. X  KEY_LOGIN,
  1971. X  KEY_MONITOR,
  1972. X  KEY_NEXT,
  1973. X  KEY_OTHER,
  1974. X  KEY_PASTE,
  1975. X  KEY_POW_DETACH,
  1976. X  KEY_PREV,
  1977. X  KEY_QUIT,
  1978. X  KEY_READ_BUFFER,
  1979. X  KEY_REDISPLAY,
  1980. X  KEY_REMOVE_BUFFERS,
  1981. X  KEY_RESET,
  1982. X  KEY_SET,
  1983. X  KEY_SHELL,
  1984. X  KEY_SUSPEND,
  1985. X  KEY_TERMCAP,
  1986. X  KEY_TIME,
  1987. X  KEY_VBELL,
  1988. X  KEY_VERSION,
  1989. X  KEY_WIDTH,
  1990. X  KEY_WINDOWS,
  1991. X  KEY_WRAP,
  1992. X  KEY_WRITE_BUFFER,
  1993. X  KEY_XOFF,
  1994. X  KEY_XON,
  1995. X  KEY_EXTEND,
  1996. X  KEY_X_WINDOWS,
  1997. X  KEY_BONUSWINDOW,
  1998. X  KEY_CREATE,
  1999. X};
  2000. X
  2001. struct key 
  2002. X{
  2003. X  enum keytype type;
  2004. X  char **args;
  2005. X};
  2006. X
  2007. X#ifdef NETHACK
  2008. X#    define Msg_nomem Msg(0, "You feel stupid.")
  2009. X#else
  2010. X#    define Msg_nomem Msg(0, "Out of memory.")
  2011. X#endif
  2012. X
  2013. X#ifdef DEBUG
  2014. X#    define debug(x) {fprintf(dfp,x);fflush(dfp);}
  2015. X#    define debug1(x,a) {fprintf(dfp,x,a);fflush(dfp);}
  2016. X#    define debug2(x,a,b) {fprintf(dfp,x,a,b);fflush(dfp);}
  2017. X#    define debug3(x,a,b,c) {fprintf(dfp,x,a,b,c);fflush(dfp);}
  2018. X    extern FILE *dfp;
  2019. X#else
  2020. X#    define debug(x) {}
  2021. X#    define debug1(x,a) {}
  2022. X#    define debug2(x,a,b) {}
  2023. X#    define debug3(x,a,b,c) {}
  2024. X#endif
  2025. X
  2026. X#if defined(__STDC__)
  2027. X# define __P(a) a
  2028. X#else
  2029. X# define __P(a) ()
  2030. X# define const
  2031. X#endif
  2032. X
  2033. X#ifdef hpux
  2034. X# define setreuid(ruid, euid) setresuid(ruid, euid, -1)
  2035. X# define setregid(rgid, egid) setresgid(rgid, egid, -1)
  2036. X#endif
  2037. X
  2038. X#if !defined(SYSV) || defined(sun) || defined(RENO) || defined(xelos)
  2039. X# define BSDWAIT
  2040. X#endif
  2041. END_OF_FILE
  2042. if test 10535 -ne `wc -c <'screen.h'`; then
  2043.     echo shar: \"'screen.h'\" unpacked with wrong size!
  2044. fi
  2045. # end of 'screen.h'
  2046. fi
  2047. if test -f 'window.c' -a "${1}" != "-c" ; then 
  2048.   echo shar: Will not clobber existing file \"'window.c'\"
  2049. else
  2050. echo shar: Extracting \"'window.c'\" \(13890 characters\)
  2051. sed "s/^X//" >'window.c' <<'END_OF_FILE'
  2052. X/* Copyright (c) 1991
  2053. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  2054. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  2055. X * Copyright (c) 1987 Oliver Laumann
  2056. X *
  2057. X * This program is free software; you can redistribute it and/or modify
  2058. X * it under the terms of the GNU General Public License as published by
  2059. X * the Free Software Foundation; either version 1, or (at your option)
  2060. X * any later version.
  2061. X *
  2062. X * This program is distributed in the hope that it will be useful,
  2063. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2064. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2065. X * GNU General Public License for more details.
  2066. X *
  2067. X * You should have received a copy of the GNU General Public License
  2068. X * along with this program (see the file COPYING); if not, write to the
  2069. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2070. X *
  2071. X * Noteworthy contributors to screen's design and implementation:
  2072. X *    Wayne Davison (davison@borland.com)
  2073. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  2074. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  2075. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  2076. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  2077. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  2078. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  2079. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  2080. X *    Marc Boucher (marc@CAM.ORG)
  2081. X *
  2082. X ****************************************************************
  2083. X */
  2084. X
  2085. X#ifndef lint
  2086. X  static char rcs_id[] = "$Id: window.c,v 1.22 91/10/08 15:11:00 mlschroe Exp $ FAU";
  2087. X#endif
  2088. X
  2089. X#include <stdio.h>
  2090. X#include <sys/types.h>
  2091. X#include <signal.h>
  2092. X#ifndef sun
  2093. X#include <sys/ioctl.h>
  2094. X#endif
  2095. X
  2096. X#ifdef MIPS
  2097. extern int errno;
  2098. X#endif
  2099. X
  2100. X#include "config.h"
  2101. X#include "screen.h"
  2102. X#include "extern.h"
  2103. X
  2104. static void FreeScrollback __P((struct win *));
  2105. X
  2106. static int ResizeHistArray __P((struct win *, char ***, int, int, int));
  2107. static int ResizeScreenArray __P((struct win *, char ***, int, int, int));
  2108. static void FreeArray __P((char ***, int));
  2109. X
  2110. extern TermcapCOLS, TermcapROWS;
  2111. extern int maxwidth;
  2112. extern int default_width, default_height, screenwidth, screenheight;
  2113. extern char *blank, *null, *OldImage, *OldAttr;
  2114. extern char *OldFont, *LastMsg;
  2115. extern struct win *wtab[], *fore;
  2116. extern int WinList, ForeNum;
  2117. extern char *Z0, *Z1, *WS;
  2118. extern int Z0width, Z1width;
  2119. X
  2120. extern int Detached;
  2121. X
  2122. X#ifdef TIOCSWINSZ
  2123. X  struct winsize glwz;
  2124. X#endif
  2125. X
  2126. X/*
  2127. X * ChangeFlag:   0: try to modify no window
  2128. X *               1: modify fore (and try to modify no other)
  2129. X *               2: modify all windows
  2130. X *
  2131. X * Note: Activate() is only called if change_flag == 1
  2132. X *       i.e. on a WINCH event
  2133. X */
  2134. X
  2135. void
  2136. CheckScreenSize(change_flag)
  2137. int change_flag;
  2138. X{
  2139. X  int width, height, n;
  2140. X  struct win *p;
  2141. X
  2142. X  if (Detached)
  2143. X    {
  2144. X      debug("CheckScreenSize: Detached -> No check.\n");
  2145. X      return;
  2146. X    }
  2147. X#ifdef TIOCSWINSZ
  2148. X  if (ioctl(0, TIOCGWINSZ, &glwz) != 0)
  2149. X    {
  2150. X      debug1("CheckScreenSize: ioctl(0, TIOCGWINSZ) errno %d\n", errno);
  2151. X      width = TermcapCOLS;
  2152. X      height = TermcapROWS;
  2153. X    }
  2154. X  else
  2155. X    {
  2156. X      width = glwz.ws_col;
  2157. X      height = glwz.ws_row;
  2158. X      if (width == 0)
  2159. X        width = TermcapCOLS;
  2160. X      if (height == 0)
  2161. X        height = TermcapROWS;
  2162. X    }
  2163. X#else
  2164. X  width = TermcapCOLS;
  2165. X  height = TermcapROWS;
  2166. X#endif
  2167. X  
  2168. X  debug2("CheckScreenSize: screen is (%d,%d)\n", width, height);
  2169. X
  2170. X  if (change_flag == 2)
  2171. X    {
  2172. X      for (n = WinList; n != -1; n = p->WinLink)
  2173. X        {
  2174. X          p = wtab[n];
  2175. X          ChangeWindowSize(p, width, height);
  2176. X    }
  2177. X    }
  2178. X  if (screenwidth == width && screenheight == height)
  2179. X    {
  2180. X      debug("CheckScreenSize: No change -> return.\n");
  2181. X      return;
  2182. X    }
  2183. X  ChangeScreenSize(width, height, change_flag);
  2184. X  if (change_flag == 1 && WinList != -1)    /* was HasWindow */
  2185. X    Activate ();
  2186. X}
  2187. X
  2188. void
  2189. ChangeScreenSize(width, height, change_fore)
  2190. int width, height;
  2191. int change_fore;
  2192. X{
  2193. X  struct win *p;
  2194. X  int n, wwi;
  2195. X
  2196. X  if (screenwidth == width && screenheight == height)
  2197. X    {
  2198. X      debug("ChangeScreenSize: no change\n");
  2199. X      return;
  2200. X    }
  2201. X  debug3("ChangeScreenSize to (%d,%d) (change_fore: %d)\n",width, height, change_fore);
  2202. X  screenwidth = width;
  2203. X  screenheight = height;
  2204. X
  2205. X  if (WS)
  2206. X    {
  2207. X      default_width = TermcapCOLS;
  2208. X      default_height = TermcapROWS;
  2209. X    }
  2210. X  else
  2211. X    {
  2212. X      if (Z0 && (width == Z0width || width == Z1width) &&
  2213. X          (TermcapCOLS == Z0width || TermcapCOLS == Z1width))
  2214. X        default_width = TermcapCOLS;
  2215. X      else
  2216. X        default_width = width;
  2217. X      default_height = height;
  2218. X    }
  2219. X  debug2("Default size: (%d,%d)\n",default_width, default_height);
  2220. X  if (change_fore)
  2221. X    {
  2222. X      if (WinList != -1 && change_fore) /* was HasWindow */
  2223. X        {
  2224. X          debug("Trying to change fore.\n");
  2225. X          ChangeWindowSize(fore, width, height);
  2226. X        }
  2227. X    }
  2228. X  if (WS == NULL)
  2229. X    {
  2230. X      /* We have to adapt all windows */
  2231. X      for (n = WinList; n != -1; n = p->WinLink)
  2232. X        {
  2233. X          p = wtab[n];
  2234. X          debug1("Trying to change window %d.\n",n);
  2235. X          wwi = width;
  2236. X          if (Z0 && (width==Z0width || width==Z1width))
  2237. X        {
  2238. X          if (p->width > (Z0width + Z1width) / 2)
  2239. X        wwi = Z0width;
  2240. X          else
  2241. X        wwi = Z1width;
  2242. X        }
  2243. X          ChangeWindowSize(p, wwi, height);
  2244. X        }
  2245. X    }
  2246. X}
  2247. X
  2248. int
  2249. ChangeScrollback(p, histheight, histwidth)
  2250. struct win *p;
  2251. int histheight, histwidth;
  2252. X{
  2253. X  if (histheight > MAXHISTHEIGHT)
  2254. X    histheight = MAXHISTHEIGHT;
  2255. X  debug2("ChangeScrollback(..., %d, %d)\n", histheight, histwidth);
  2256. X  debug2("  was %d, %d\n", p->histheight, p->width);
  2257. X
  2258. X  if (histheight == 0)
  2259. X    {
  2260. X      FreeScrollback(p);
  2261. X      return 0;
  2262. X    }
  2263. X
  2264. X  if (ResizeHistArray(p, &p->ihist, histwidth, histheight, 1)
  2265. X      || ResizeHistArray(p, &p->ahist, histwidth, histheight, 0)
  2266. X      || ResizeHistArray(p, &p->fhist, histwidth, histheight, 0))
  2267. X    {
  2268. X      debug("   failed, removing all histbuf\n");
  2269. X      FreeScrollback(p);
  2270. X      Msg_nomem;
  2271. X      return (-1);
  2272. X    }
  2273. X  if (p->histheight != histheight)
  2274. X    p->histidx = 0;
  2275. X  p->histheight = histheight;
  2276. X
  2277. X  return(0);
  2278. X}
  2279. X
  2280. static void FreeScrollback(p)
  2281. struct win *p;
  2282. X{
  2283. X  FreeArray(&p->ihist, p->histheight);
  2284. X  FreeArray(&p->ahist, p->histheight);
  2285. X  FreeArray(&p->fhist, p->histheight);
  2286. X  p->histheight = 0;
  2287. X}
  2288. X
  2289. static int
  2290. ResizeHistArray(p, arr, wi, hi, fillblank)
  2291. struct win *p;
  2292. char ***arr;
  2293. int wi, hi, fillblank;
  2294. X{
  2295. X  char **narr, **np, **onp, **onpe;
  2296. X  int t, x, first;
  2297. X
  2298. X  if (p->width == wi && p->histheight == hi)
  2299. X    return(0);
  2300. X  if (p->histheight != hi)
  2301. X    {
  2302. X      if ((narr = (char **)calloc(sizeof(char *), hi)) == NULL)
  2303. X    {
  2304. X      FreeArray(arr, p->histheight);
  2305. X      return(-1);
  2306. X    }
  2307. X      np = narr;
  2308. X      onp = (*arr) + p->histidx;
  2309. X      onpe = (*arr) + p->histheight;
  2310. X      first = p->histheight - hi;
  2311. X      if (first<0)
  2312. X     np-=first;
  2313. X      for(t=0; t<p->histheight; t++)
  2314. X    {
  2315. X          if (t-first >=0 && t-first < hi)
  2316. X        *np++ = *onp;
  2317. X      else
  2318. X        Free(*onp);
  2319. X      if (++onp == onpe)
  2320. X        onp = *arr;
  2321. X    }
  2322. X      if (*arr)
  2323. X    Free(*arr);
  2324. X    }
  2325. X  else
  2326. X    narr = *arr;
  2327. X  for (t=0, np=narr; t<hi; t++, np++)
  2328. X    {
  2329. X      x = p->width;
  2330. X      if (*np == 0)
  2331. X    {
  2332. X      *np = (char *)malloc(wi);
  2333. X          x = 0;
  2334. X    }
  2335. X      else if (p->width != wi)
  2336. X    {
  2337. X      *np = (char *)xrealloc(*np, wi);
  2338. X    }
  2339. X      if (*np == 0)
  2340. X    {
  2341. X      FreeArray(&narr, hi);
  2342. X      return(-1);
  2343. X    }
  2344. X      if (x<wi)
  2345. X    {
  2346. X      if (fillblank)
  2347. X        bclear(*np+x, wi-x);
  2348. X      else
  2349. X        bzero(*np+x, wi-x);
  2350. X    }
  2351. X    }
  2352. X  *arr = narr;
  2353. X  return(0);
  2354. X}
  2355. X      
  2356. X
  2357. static int
  2358. ResizeScreenArray(p, arr, wi, hi, fillblank)
  2359. struct win *p;
  2360. char ***arr;
  2361. int wi, hi, fillblank;
  2362. X{
  2363. X  int minr;
  2364. X  char **cp;
  2365. X
  2366. X  if (p->width == wi && p->height == hi)
  2367. X    return(0);
  2368. X
  2369. X  if (hi > p->height)
  2370. X    minr = p->height;
  2371. X  else
  2372. X    minr = hi;
  2373. X
  2374. X  if (p->height > hi)
  2375. X    {
  2376. X      for (cp = *arr; cp < *arr + (p->height - hi); cp++)
  2377. X    Free(*cp);
  2378. X      bcopy((char *)(*arr + (p->height - hi)), (char *)(*arr),
  2379. X        hi * sizeof(char *));
  2380. X    }
  2381. X  if (*arr && p->width != wi)
  2382. X    for (cp = *arr; cp < *arr + minr; cp++)
  2383. X      {
  2384. X    if ((*cp = (char *)xrealloc(*cp, (unsigned) wi)) == 0)
  2385. X      {
  2386. X        FreeArray(arr, p->height);
  2387. X        return(-1);
  2388. X      }
  2389. X    if (wi > p->width)
  2390. X      {
  2391. X        if (fillblank)
  2392. X          bclear(*cp + p->width, wi - p->width);
  2393. X        else
  2394. X          bzero(*cp + p->width, wi - p->width);
  2395. X      }
  2396. X      }
  2397. X  if (*arr)
  2398. X    *arr = (char **) xrealloc((char *) *arr, (unsigned) hi * sizeof(char *));
  2399. X  else
  2400. X    *arr = (char **) malloc((unsigned) hi * sizeof(char *));
  2401. X  if (*arr == 0)
  2402. X    return(-1);
  2403. X  for (cp = *arr + p->height; cp < *arr + hi; cp++)
  2404. X    {
  2405. X      if ((*cp = malloc((unsigned) wi)) == 0)
  2406. X    {
  2407. X      while (--cp >= *arr)
  2408. X        Free(*cp);
  2409. X      Free(*arr);
  2410. X          return(-1);
  2411. X    }
  2412. X      if (fillblank)
  2413. X    bclear(*cp, wi);
  2414. X      else
  2415. X    bzero(*cp, wi);
  2416. X    }
  2417. X  return(0);
  2418. X}
  2419. X
  2420. static void
  2421. XFreeArray(arr, hi)
  2422. char ***arr;
  2423. int hi;
  2424. X{
  2425. X  register char **p;
  2426. X  register int t;
  2427. X
  2428. X  if (*arr == 0)
  2429. X    return;
  2430. X  for (t = hi, p = *arr; t--; p++)
  2431. X    if (*p)
  2432. X      Free(*p);
  2433. X  Free(*arr);
  2434. X}
  2435. X
  2436. X
  2437. int
  2438. ChangeWindowSize(p, width, height)
  2439. struct win *p;
  2440. int width, height;
  2441. X{
  2442. X  int t, scr;
  2443. X  
  2444. X  if (width > maxwidth)
  2445. X    {
  2446. X      maxwidth = width;
  2447. X      debug1("New maxwidth: %d\n", maxwidth);
  2448. X      if (blank == 0)
  2449. X        blank = malloc((unsigned) maxwidth);
  2450. X      else
  2451. X        blank = xrealloc(blank, (unsigned) maxwidth);
  2452. X      if (null == 0)
  2453. X        null = malloc((unsigned) maxwidth);
  2454. X      else
  2455. X        null = xrealloc(null, (unsigned) maxwidth);
  2456. X      if (OldImage == 0)
  2457. X        OldImage = malloc((unsigned) maxwidth);
  2458. X      else
  2459. X        OldImage = xrealloc(OldImage, (unsigned) maxwidth);
  2460. X      if (OldAttr == 0)
  2461. X        OldAttr = malloc((unsigned) maxwidth);
  2462. X      else
  2463. X        OldAttr = xrealloc(OldAttr, (unsigned) maxwidth);
  2464. X      if (OldFont == 0)
  2465. X        OldFont = malloc((unsigned) maxwidth);
  2466. X      else
  2467. X        OldFont = xrealloc(OldFont, (unsigned) maxwidth);
  2468. X      if (LastMsg == 0)
  2469. X        {
  2470. X          LastMsg = malloc((unsigned) maxwidth + 1);
  2471. X          *LastMsg = 0;
  2472. X        }
  2473. X      else
  2474. X        LastMsg = xrealloc(LastMsg, (unsigned) maxwidth + 1);
  2475. X      LastMsg[maxwidth]=0;
  2476. X      if (!(blank && null && OldImage && OldAttr && OldFont && LastMsg))
  2477. X    {
  2478. nomem:      for (t = WinList; t != -1 && wtab[t] != p; t = p->WinLink) 
  2479. X        ;
  2480. X      if (t >= 0)
  2481. X        KillWindow(t);
  2482. X      Msg(0, "Out of memory -> Window destroyed !!");
  2483. X      return(-1);
  2484. X    }
  2485. X      MakeBlankLine(blank, maxwidth);
  2486. X      bzero(null, maxwidth);
  2487. X    }
  2488. X  
  2489. X  if (width == p->width && height == p->height)
  2490. X    {
  2491. X      debug("ChangeWindowSize: No change.\n");
  2492. X      return(0);
  2493. X    }
  2494. X
  2495. X  debug2("ChangeWindowSize from (%d,%d) to ", p->width, p->height);
  2496. X  debug2("(%d,%d)\n", width, height);
  2497. X
  2498. X  if (width == 0 && height == 0)
  2499. X    {
  2500. X      FreeArray(&p->image, p->height);
  2501. X      FreeArray(&p->attr, p->height);
  2502. X      FreeArray(&p->font, p->height);
  2503. X      if (p->tabs)
  2504. X    Free(p->tabs);
  2505. X      p->width = 0;
  2506. X      p->height = 0;
  2507. X      FreeScrollback(p);
  2508. X      return(0);
  2509. X    }
  2510. X
  2511. X  /* when window gets smaller, scr is the no. of lines we scroll up */
  2512. X  scr = p->height - height;
  2513. X  if (scr < 0)
  2514. X    scr = 0;
  2515. X  for (t = 0; t < scr; t++)
  2516. X    AddLineToHist(p, p->image+t, p->attr+t, p->font+t); 
  2517. X  if (ResizeScreenArray(p, &p->image, width, height, 1)
  2518. X      || ResizeScreenArray(p, &p->attr, width, height, 0)
  2519. X      || ResizeScreenArray(p, &p->font, width, height, 0))
  2520. X    {
  2521. X      goto nomem;
  2522. X    }
  2523. X  /* this won't change the height of the scrollback history buffer, but
  2524. X   * it will check the width of the lines.
  2525. X   */
  2526. X  ChangeScrollback(p, p->histheight, width);
  2527. X
  2528. X  if (p->tabs == 0)
  2529. X    {
  2530. X      /* tabs get width+1 because 0 <= x <= width */
  2531. X      if ((p->tabs = malloc((unsigned) width + 1)) == 0)
  2532. X        goto nomem;
  2533. X      t = 8;
  2534. X    }
  2535. X  else
  2536. X    {
  2537. X      if ((p->tabs = xrealloc(p->tabs, (unsigned) width + 1)) == 0)
  2538. X        goto nomem;
  2539. X      t = p->width;
  2540. X    }
  2541. X  for (t = (t + 7) & 8; t < width; t += 8)
  2542. X    p->tabs[t] = 1; 
  2543. X  p->height = height;
  2544. X  p->width = width;
  2545. X  if (p->x >= width)
  2546. X    p->x = width - 1;
  2547. X  if ((p->y -= scr) < 0)
  2548. X    p->y = 0;
  2549. X  if (p->Saved_x >= width)
  2550. X    p->Saved_x = width - 1;
  2551. X  if ((p->Saved_y -= scr) < 0)
  2552. X    p->Saved_y = 0;
  2553. X  if (p->autoaka > 0) 
  2554. X    if ((p->autoaka -= scr) < 1)
  2555. X      p->autoaka = 1;
  2556. X  p->top = 0;
  2557. X  p->bot = height - 1;
  2558. X#ifdef TIOCSWINSZ
  2559. X  if (p->ptyfd && p->wpid)
  2560. X    {
  2561. X      glwz.ws_col = width;
  2562. X      glwz.ws_row = height;
  2563. X      debug("Setting pty winsize.\n");
  2564. X      if (ioctl(p->ptyfd, TIOCSWINSZ, &glwz))
  2565. X    debug2("SetPtySize: errno %d (fd:%d)\n", errno, p->ptyfd);
  2566. X# if defined(STUPIDTIOCSWINSZ) && defined(SIGWINCH)
  2567. X#  ifdef POSIX
  2568. X      pgrp = tcgetpgrp(p->ptyfd);
  2569. X#  else
  2570. X      if (ioctl(p->ptyfd, TIOCGPGRP, &pgrp))
  2571. X    pgrp = 0;
  2572. X#  endif
  2573. X      if (pgrp)
  2574. X    {
  2575. X      debug1("Sending SIGWINCH to pgrp %d.\n", pgrp);
  2576. X      if (killpg(pgrp, SIGWINCH))
  2577. X        debug1("killpg: errno %d\n", errno);
  2578. X    }
  2579. X      else
  2580. X    debug1("Could not get pgrp: errno %d\n", errno);
  2581. X# endif /* STUPIDTIOCSWINSZ */
  2582. X    }
  2583. X#endif
  2584. X  return(0);
  2585. X}
  2586. X
  2587. X
  2588. void
  2589. ResizeScreen(wi)
  2590. struct win *wi;
  2591. X{
  2592. X  int width, height;
  2593. X
  2594. X  if (wi)
  2595. X    {
  2596. X      width = wi->width;
  2597. X      height = wi->height;
  2598. X    }
  2599. X  else
  2600. X    {
  2601. X      width = default_width;
  2602. X      height = default_height;
  2603. X    }
  2604. X  if (screenwidth == width && screenheight == height)
  2605. X    {
  2606. X      debug("ResizeScreen: No change\n");
  2607. X      return;
  2608. X    }
  2609. X  debug2("ResizeScreen: to (%d,%d).\n", width, height);
  2610. X  if (WS)
  2611. X    {
  2612. X      debug("ResizeScreen: using WS\n");
  2613. X      WSresize(width, height);
  2614. X      ChangeScreenSize(width, height, 0);
  2615. X    }
  2616. X  else if (Z0 && (width == Z0width || width == Z1width))
  2617. X    {
  2618. X      debug("ResizeScreen: using Z0/Z1\n");
  2619. X      PutStr(width == Z0width ? Z0 : Z1);
  2620. X      ChangeScreenSize(width, screenheight, 0);
  2621. X    }
  2622. X  if (screenwidth != width || screenheight != height)
  2623. X    {
  2624. X      debug2("BUG: Cannot resize from (%d,%d)",screenwidth, screenheight);
  2625. X      debug2(" to (%d,%d) !!\n", width, height);
  2626. X      if (wi)
  2627. X    ChangeWindowSize(wi, screenwidth, screenheight);
  2628. X    }
  2629. X}
  2630. X
  2631. char *
  2632. xrealloc(mem, len)
  2633. char *mem;
  2634. int len;
  2635. X{
  2636. X  register char *nmem;
  2637. X
  2638. X  if (nmem = realloc(mem, len))
  2639. X    return(nmem);
  2640. X  free(mem);
  2641. X  return((char *)0);
  2642. X}
  2643. END_OF_FILE
  2644. if test 13890 -ne `wc -c <'window.c'`; then
  2645.     echo shar: \"'window.c'\" unpacked with wrong size!
  2646. fi
  2647. # end of 'window.c'
  2648. fi
  2649. echo shar: End of archive 3 \(of 8\).
  2650. cp /dev/null ark3isdone
  2651. MISSING=""
  2652. for I in 1 2 3 4 5 6 7 8 ; do
  2653.     if test ! -f ark${I}isdone ; then
  2654.     MISSING="${MISSING} ${I}"
  2655.     fi
  2656. done
  2657. if test "${MISSING}" = "" ; then
  2658.     echo You have unpacked all 8 archives.
  2659.     rm -f ark[1-9]isdone
  2660. else
  2661.     echo You still need to unpack the following archives:
  2662.     echo "        " ${MISSING}
  2663. fi
  2664. ##  End of shell archive.
  2665. exit 0
  2666.